← 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?
- A.As the return type of a method that may not find a result
- B.As the type of a field in an entity class
- C.As a method parameter for optional arguments
- 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 →