Intermediate Java
Q52 / 100

What is the purpose of the Optional class in Java 8?

Correct! Well done.

Incorrect.

The correct answer is B) To represent a value that may or may not be present, avoiding NullPointerException

B

Correct Answer

To represent a value that may or may not be present, avoiding NullPointerException

Explanation

Optional<T> forces callers to handle the absent-value case explicitly, reducing NullPointerExceptions.

Progress
52/100