Oracle Certified Professional Java Se 8 Programmer · Free Practice Question Hard

Question 3

Given code of Test.java file: 

What will be the result of compiling and executing Test class?

  • A MRAP
  • B AMPR
  • C RPMA
  • D Runtime Exception
  • E None of the other options
Reveal correct answer

Correct answer: E

Explanation

Streams are lazily evaluated, which means if terminal operations such as: forEach, count, toArray, reduce, collect, findFirst, findAny, anyMatch, allMatch, sum, min, max, average etc. are not present, the given stream pipeline is not evaluated and hence peek() method doesn't print anything on to the console.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need