Quiz on FileReader and BufferedReader

This is a practice quiz. The results are not recorded anywhere and do not affect your grade. The questions on this quiz might not appear in any quiz or test that does count toward your grade.

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.


1. What is the ancestor class of all character-oriented input streams?

a.    Reader
b.    BufferedReader
c.    FileReader
d.    WeeklyReader

Correct Answer Is:


2. What stream type provides input from a disk file?

a.    FileReader
b.    InputStreamReader
c.    StringReader
d.    FilterReader

Correct Answer Is:


3. What class does readLine() belong to?

a.    FileReader
b.    InputStreamReader
c.    Reader
d.    BufferedReader

Correct Answer Is:


4. What data type does readLine() return?

a.    char
b.    byte[]
c.    String
d.    int

Correct Answer Is:


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

Correct Answer Is:


6. What happens if readLine() encounters an error?

a.    Nothing; the program must examine the returned value to see if it makes sense.
b.    The program immediately halts.
c.    It throws an IOException.
d.    It returns null

Correct Answer Is:


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()

Correct Answer Is:


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 interpretted 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.

Correct Answer Is:


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.

Correct Answer Is:


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) )

Correct Answer Is:


The number you got right:       Percent Correct:       Letter Grade:   


Click here

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.