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.

Related questions

0 votes
asked Apr 13, 2023 in JAVA by Robin
0 votes
asked Sep 12, 2022 in Scala Constructs by Robin
...