Quiz on Byte Output Steams

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 best definition of a binary file?

a.    A file whose bytes contain only ones and zeros.
b.    A file whose bytes might contain any pattern of ones and zeros.
c.    A file that only contains bytes.
d.    A file that does not contain any bytes that represent characters.

Correct Answer Is:

2. How many patterns can be formed from 8 bits?

a.    8
b.    16
c.    64
d.    256 == 28

Correct Answer Is:

3. What abstract data type is the ancestor of all streams that output byte-oriented data?

a.    OutputStream
b.    ByteOutputStream
c.    BinaryOutputStream
d.    ByteStream

Correct Answer Is:

4. Which of the following opens the file "myData.stuff" for output first deleting any file with that name?

a.    FileOutputStream fos = new FileOutputStream( "myData.stuff", true )
b.    FileOutputStream fos = new FileOutputStream( "myData.stuff")
c.    DataOutputStream dos = new DataOutputStream( "myData.stuff" )
d.    FileOutputStream fos = new FileOutputStream( new BufferedOutputStream( "myData.stuff") )

Correct Answer Is:

5. What is an advantage of using a DataOutputStream?

a.    A DataOutputStream has convenient methods for output of primitive data types.
b.    A DataOutputStream translates primitive data into characters.
c.    A DataOutputStream uses the particular data format of the computer it is running on.
d.    A DataOutputStream need not be used with other streams.

Correct Answer Is:

6. What is the name of the printed output of a program that shows the byte-by-byte contents of a binary file?

a.    Charmed Display
b.    Hex Dump
c.    Binary Refuse
d.    Pattern Listing

Correct Answer Is:

7. A program writes ten int values to a new file. How many bytes long is the file?

a.    Depends on the size of the values in the ints.
b.    10
c.    20
d.    40

Correct Answer Is:

8. What is the DataOutputStream method that writes double precision floating point values to a stream?

a.    write()
b.    writeDouble()
c.    writeFloat()
d.    writeBytes()

Correct Answer Is:

9. One of the bit patterns that an int variable might hold, as it might be written on paper or on a blackboard, is:

00000000 01010101 11111111 00001111

Which eight bits are the low-order byte?

a.    00000000
b.    01010101
c.    11111111
d.    00001111

Correct Answer Is:

10. What DataOutputStream method reports the number of bytes written to a stream so far?

a.    size()
b.    length()
c.    written()
d.    flush()

Correct Answer Is:

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

Click here (If you have just 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 on reload to clear the old answers.)