Close
« Tutorial

Spring MVC - java.util.Optional as Handler Parameter MCQ

0/13
0 ✓
0 ✗

1. Spring MVC supports java.util.Optional as a handler method parameter type. What is it an alternative to?

2. Which Java version introduced java.util.Optional?

3. From which Spring version is java.util.Optional supported as a handler method parameter?

4. A handler method has a @RequestParam parameter with no extra settings. What happens if the request does not send that parameter?

5. Which setting makes a @RequestParam optional without using Optional?

@RequestParam(value = "dept", ______ ) String deptName

6. A String parameter uses @RequestParam(required = false). What value does the method get when the request does not send it?

7. A parameter is declared as Optional and the request does not send it. What does the method receive?

8. When a parameter is declared as Optional, do you also need to set required = false to avoid a 400 error?

9. Which parameter declaration correctly uses Optional for a request parameter?

public String handle(______ ) { ... }

10. Which Optional method returns the value if present, or a given default value if it is empty?

String dept = deptName.______("default dept");

11. Besides @RequestParam, which annotations can be used with java.util.Optional?

12. Why does Spring support java.util.Optional in handler methods?

13. In which package is the Optional class used for handler parameters found?

Join