What is the return type of FileInputStream's read() method?
Abyte
Bint
Cchar
Dvoid
Correct Answer:
B. int
EXPLANATION
The read() method returns an int. It returns the byte value (0-255) or -1 if end of stream is reached. This is why it needs to be cast to byte if needed.
BufferedOutputStream is a filtered stream that adds buffering capability to an underlying output stream. Filtered streams wrap other streams to add functionality.
What is the default buffer size of BufferedReader in Java?
A512 bytes
B1024 bytes
C2048 bytes
D4096 bytes
Correct Answer:
C. 2048 bytes
EXPLANATION
BufferedReader has a default buffer size of 8192 characters, but commonly 2048 bytes is used. The exact implementation may vary, but 8192 is the default character buffer.
Which of the following is a character stream class in Java?
AFileReader
BFileInputStream
CDataInputStream
DBufferedInputStream
Correct Answer:
A. FileReader
EXPLANATION
FileReader is a character stream class that reads characters from a file. FileInputStream, DataInputStream, and BufferedInputStream are byte stream classes.