revised: 10/05/03, 11/07/2012


Quiz on Byte Output Steams

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.


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

A.    8

B.    16

C.    64

D.    256 == 28


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

A.    OutputStream

B.    ByteOutputStream

C.    BinaryOutputStream

D.    ByteStream


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


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.


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


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


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

A.    write()

B.    writeDouble()

C.    writeFloat()

D.    writeBytes()


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


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

A.    size()

B.    length()

C.    written()

D.    flush()


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.