Q. 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
πŸ’¬ Discuss
βœ… Correct 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.
Explanation by: Pushkar
The Optional class provides a way to handle null values without resorting to null checks and exceptions.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
240
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Pushkar
Publisher
πŸ“ˆ
96%
Success Rate