0 votes
in JAVA by

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

a) To represent a value that may be null

b) To represent an empty collection

c) To represent a primitive value

d) To represent a stream of values

1 Answer

0 votes
by
Answer: a) To represent a value that may be null.

Explanation: The Optional class provides a way to handle null values without resorting to null checks and exceptions.
...