🎙 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 6 of 10

Which is a recommended use of Optional?

Which is a recommended use of Optional?

  1. A.As the return type of a method that may not find a result
  2. B.As the type of a field in an entity class
  3. C.As a method parameter for optional arguments
  4. D.Wrapped around a List that may be empty
Answer & explanation

Correct answer: As the return type of a method that may not find a result

Optional was designed for return values. For lists, return an empty list.

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 →