revised: 10/05/03

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

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

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

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

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.