Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What is the purpose of the Optional class in Java?
Consider how you would check for null values.
How do you create an Optional instance from a potentially null value?
Remember the method name that indicates possible absence of value.
What does the Optional class help prevent in Java?
Recall the common exception types Java programs face.
True or False: Optional can hold null values.
Think about what Optional encapsulates.
Write a method using Optional to return an integer value from a collection of numbers, where the number is searched based on criteria (e.g., greater than 10).
Use streams to filter and find the first matching value.
Design an API method that returns a user based on username, using Optional in its return type.
Consider how the absence of a user will be indicated.
4 more questions in this section. Enroll free to practise them all.
Enroll free