--:--









Quiz for Optional, Method References

Course: JAVA | Subject: Java | Topic: Java 8 Features



Logo

Q1: What does the Optional class help with in Java 8?

Logo

Q2: How do you create an empty Optional?

Logo

Q3: Which method is used to get the value inside Optional if present?

Logo

Q4: What is the purpose of Optional.ofNullable()?

Logo

Q5: Which method reference is valid syntax?

Logo

Q6: Which functional interface is commonly used with method references?

Logo

Q7: What does Optional.orElse() do?

Logo

Q8: Which is not a method of Optional?

Logo

Q9: Which type of method reference is used for static methods?

Logo

Q10: Which method will throw NoSuchElementException if value not present?

Logo

Q11: What is the output of Optional.of(null)?

Logo

Q12: What type does Optional<T> represent?

Logo

Q13: Which method reference syntax creates a new object?

Logo

Q14: Optional.map() is used to:

Logo

Q15: Optional.ifPresent() accepts:

Logo

Q16: What is the purpose of orElseGet()?

Logo

Q17: Which is a benefit of method references?

Logo

Q18: What does Optional.filter() do?

Logo

Q19: Which interface works with constructor references?

Logo

Q20: Optional is part of which package?

Are you ready to start test? Set your time limit