Java OCA OCP Practice Question 2226

Question

Which statements describe a java.io stream class and cannot be applied to a java.util.stream.Stream class? (Choose three.)

  • A. Can be used with try-with-resources statement
  • B. Includes a class or set of classes used solely for working with character data
  • C. Requires all data objects to implement Serializable
  • D. Some classes contain a flush() method.
  • E. Some classes contain a method to skip over data.
  • F. Some classes contain a method to sort the data.


A, B, D.

Note

Option A is correct because the java.io stream classes implement Closeable and can be used with try-with-resources statements, while java.util.stream.Stream does not implement Closeable.

Option B is correct since the Reader/Writer classes are used for handling character data.

There are primitive stream classes in java.util.stream, but none for handling character data, such as CharStream.

Option C is incorrect because neither requires all data objects to implement Serializable.

Option D is correct since flush() is found in Writer and OutputStream but not in any of the java.util.stream classes.

Option E is incorrect since both types of streams contain a skip() method in some of their classes.

Lastly, Option F is incorrect.

There is no sort method found in any of the java.io classes.

While there is a sorted() method in java.util.stream.Stream, the question is asking about what features are available in a java.io stream class and not in a java.util.stream.Stream class.




PreviousNext

Related