1: What is the purpose of the `Optional` class in Java?
2: Which method is used to create an `Optional` with a non-null value?
3: Which method is used to access the value if present or return a default value?
4: What does the method isPresent() check in the Optional class?
5: Which method is used to apply a mapping function to the value if it is present?
6: What does the orElseThrow() method do?
7: What is the purpose of the filter() method in the Optional class?
8: How does the ifPresent() method differ from orElseGet()?
9: What is the purpose of the flatMap() method in the Optional class?
10: Which method is used to perform an action based on the presence or absence of a value, without returning any result?
0 Comments