Quiz





Quiz

To see whether you took a big enough byte from the tree of knowledge during this hour, answer the following questions about input and output streams in Java.

Questions

1:

Which of the following techniques can be used to convert an array of bytes into a string?

  1. Call the array's toString() method.

  2. Convert each byte to a character, and then assign each one to an element in a String array.

  3. Call the String() constructor method with the array as an argument.

2:

What kind of stream is used to read from a file in a Java program?

  1. An input stream

  2. An output stream

  3. Either

3:

What method of the File class can be used to determine the size of a file?

  1. getSize()

  2. read()

  3. length()

Answers

A1:

c. You can deal with each byte individually, as suggested in answer b., but you can easily create strings from other data types.

A2:

a. An input stream is created from a File object or by providing a filename to the input stream's constructor method.

A3:

c. This method returns a long representing the number of bytes in the stream.


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows