<%@ include file="../../ga4.jsp" %> Java DataStreams - Quiz Explanation
 

Java DataStreams API - Quiz Explanation


1. To read Java data types, you can create an instance of what kind of class and associate it with a target?
Please select the best answer.
  A. DataInput
  B. DataInputStream

C. InputStream

The correct answer is B. DataInputStream instances have access to methods that allow you to read Java data types.

2. To create a DataInputStream tied to the standard input, you can write
Please select the best answer.

A. new DataInputStream(System.out);

B. new DataInputStream("in");

C. new DataInputStream(System.in);

The correct answer is C. The standard input is System.in.

3. Given a BufferedReader object reference named dataIn, which line of code would read one line of data into a String object reference named s?
Please select the best answer.
  A. s = dataIn.readLine()

B. s = dataIn.read()

C. s.readLine()
  The correct answer is A. The readLine() method reads a line of characters at a time. With a BufferedReader object, you can do this kind of thing. With other types of Stream objects, you are sometimes restricted to reading a byte or single data type (int, double, etc.) at a time.