1.

What is Optional object used for?(a) Optional is used for optional runtime argument(b) Optional is used for optional spring profile(c) Optional is used to represent null with absent value(d) Optional means it’s not mandatory for method to return objectThe question was asked in final exam.My doubt is from Java 8 Features topic in chapter Autoboxing & Miscellaneous of Java

Answer» CORRECT answer is (c) Optional is used to represent null with ABSENT value

Explanation: Optional object is used to represent null with absent value. This class has various utility methods to facilitate code to HANDLE values as ‘available’ or ‘not available’ instead of CHECKING null values.


Discussion

No Comment Found

Related InterviewSolutions