Close
« Tutorial

Spring MVC - Query Parameters To Enum MCQ

0/13
0 ✓
0 ✗

1. Which annotation is used to map a query parameter to a handler method parameter of an enum type?

2. How does Spring convert a single query parameter string to an enum constant?

3. Do you need to write extra conversion code to use an enum as a @RequestParam parameter type?

4. An enum has the constants SMALL, MEDIUM and LARGE. The handler method has @RequestParam("size") with this enum type. Which request is mapped to MEDIUM?

5. The query value must match the enum constant in which way?

6. Which parameter type lets you receive many enum values from repeated query parameters like ?color=RED&color=BLUE?

public String handle(@RequestParam("color") ______ colors) { ... }

7. How do you send several enum values for the same query parameter name?

8. Which use of an enum with query parameters is converted automatically by Spring?

9. Which handler parameter type can receive all query parameters together as a map with several values per key?

10. When enum constants are used as query parameter names (keys), what do you need to do?

11. Which code correctly converts a String key to an enum constant manually?

enum Day { MON, TUE, WED }
String key = "TUE";
Day day = ______;

12. What happens when Enum.valueOf() gets a name that does not match any constant?

13. Why should you handle IllegalArgumentException when you convert query keys to an enum manually?

14. Why is it useful to use an enum type for a query parameter?

Join