0 votes
in JAVA by
Which of the following is true about the Optional class in Java 8?

a) It is used to represent a value that may be absent.

b) It is used to represent a collection of values.

c) It is used to represent a stream of values.

d) It is used to represent a function that takes an optional parameter.

1 Answer

0 votes
by

Answer: a) It is used to represent a value that may be absent.

Explanation: The Optional class is a container object that may or may not contain a non-null value. It is used to avoid NullPointerExceptions and make code more readable.

Related questions

0 votes
asked Apr 13, 2023 in JAVA by Robin
0 votes
0 votes
asked Apr 24 in JAVA by Robin
...