Java OCA OCP Practice Question 1625

Question

What does the following output?

ArrayDeque<Integer> dice = new ArrayDeque<>();
dice.offer(3);
dice.offer(2);
dice.offer(4);
System.out.print(dice.stream().filter(n -> n != 4));
  • A. 2
  • B. 3
  • C. The code does not compile.
  • D. None of the above


D.

Note

The code correctly creates an ArrayDeque with three elements.

The stream pipeline does compile.

There is no terminal operation.

The stream is never evaluated.

This is definitely not one of the listed choices, so Option D is correct.




PreviousNext

Related