Which statement is true about java.util.stream.Stream?
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.
Correct Answer is A because after it reaches its terminal operation cant be consumed take note
IllegalStateException
A
B
A) stream can be consumed many times, such as peek()
C) stream won’t change the source data
D) not always faster
even with peak() one can;’t consume stream twice..
other explanation are good.
peek() can consume stream twice.
Listnums=Arrays.asList(10,20,8);
System.out.println(
nums.stream()
.peek(System.out::println)
.peek(System.out::println)
.count());
this code runs with no problem.
peek() return always new Stream
A
Correct answer is A, I agree with @Pete. 1zo-809 prep brought me here and unfortunately they are as wrong as the exam guide am using.
Correct answer is A. Beware with the answers that can read this…