🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Optional: all 10 questions

Quiz: Java Optional · Question 8 of 10

Which stream operation returns an Optional?

Which stream operation returns an Optional?

  1. A.filter
  2. B.map
  3. C.findFirst
  4. D.count
Answer & explanation

Correct answer: findFirst

findFirst may find nothing in an empty stream, so it returns Optional<T>. count returns a long.

Can you get the rest right without peeking?

Take the timed Quiz: Java Optional quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →