Java SE 8 Programmer II — Question 52
Which statement is true about java.util.stream.Stream?
Answer options
- A. A stream cannot be consumed more than once.
- B. The execution mode of streams can be changed during processing.
- C. Streams are intended to modify the source data.
- D. A parallel stream is always faster than an equivalent sequential stream.
- E. Stream operation accepts lambda expressions as its parameters.
Correct answer: A
Explanation
The correct statement is A, as once a stream has been processed, it cannot be reused or consumed again. Option B is incorrect because the execution mode cannot be changed after a stream is created. Option C is misleading since streams are designed for processing data without modifying the source. Option D is also false as parallel streams do not guarantee better performance in all cases, and it depends on the specific use case. Option E is accurate, but it is not the correct answer to the question asked.