Uploaded by nghiemptce160353

File Reader

advertisement
1. What is the ancestor class of all character-oriented input streams?
A.
Reader
B.
BufferedReader
C.
FileReader
D.
WeeklyReader
2. What stream type provides input from a disk file?
A.
FileReader
B.
InputStreamReader
C.
StringReader
D.
FilterReader
3. What class does readLine() belong to?
A.
FileReader
B.
InputStreamReader
C.
Reader
D.
BufferedReader
4. What data type does readLine() return?
A.
char
B.
byte[]
C.
String
D.
int
5. What value does readLine() return upon encountering end-of-file?
A.
No value; it throws an exception.
B.
The empty string ""
C.
null
D.
0
6. What happens if readLine() encounters an error?
A.
sense.
Nothing; the program must examine the returned value to see if it makes
B.
The program immediately halts.
C.
It throws an IOException.
D.
It returns null
7. What method is used to notify the operating system that a file is no longer needed?
A.
quit()
B.
exit()
C.
flush()
D.
close()
8. Should FileReader be used to read a Java bytecode (*.class) file?
A.
No—bytecode files can only be executed, never read.
B. No—the bytes in bytecode files are not intended to be interpreted as
characters.
C.
Yes—any file can be read with FileReader.
D. Maybe—as long as the bytecodes were created on the same computer as
the program using FileReader.
9. Can a FileReader object be constructed that is not connected to any file?
A.
No—the constructor must specify a file.
B. No—a FileReader is always connected to a file, but you can switch which
file it is connected to.
C.
Yes—you can use a constructor without any file name argument.
D.
Yes—this happens if the file named in the constructor does not exist.
10. Which of the following is used in a C-style input loop?
A.
while ( source.readLine() != null )
B.
while ( (line = source.readLine()) == null )
C.
while ( (line = source.readLine()) != null )
D.
while ( line = (source.readLine() != null) )
Download