1. Which annotation is used to map a query parameter to a handler method parameter of an enum type?
Why:@RequestParam binds URL query parameters to method parameters. It works with enum types too.
2. How does Spring convert a single query parameter string to an enum constant?
Why: When a handler parameter has an enum type, Spring converts the query parameter to Enum value by using its ConversionService/StringToEnumConverterFactory, which uses Enum.valueOf().
3. Do you need to write extra conversion code to use an enum as a @RequestParam parameter type?
Why: For a simple enum parameter, Spring does the conversion automatically. No extra code is needed.
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?
Why: The query value must match the name of an enum constant. Here size=MEDIUM matches the constant MEDIUM.
5. The query value must match the enum constant in which way?
Why:Enum.valueOf() looks for an exact name match, so the spelling and the letter case must be the same as the constant name.
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) { ... }
Why: An array of the enum type, like Color[], receives all the values of a repeated query parameter. Spring converts each value to an enum constant. Note that List<Color> also works for repeated query parameters
7. How do you send several enum values for the same query parameter name?
Why: Repeat the same parameter name for each value, for example ?name=A&name=B. Spring collects them into an array.
8. Which use of an enum with query parameters is converted automatically by Spring?
Why: Spring converts the query parameter value to an enum automatically. Map keys are not converted, so you must do that yourself.
9. Which handler parameter type can receive all query parameters together as a map with several values per key?
Why:@RequestParam on a MultiValueMap collects all query parameters into one map. Each key can have a list of values.
10. When enum constants are used as query parameter names (keys), what do you need to do?
Why: Spring does not convert map keys to enum constants. The keys stay as String, so you convert them manually in your code.
11. Which code correctly converts a String key to an enum constant manually?
enum Day { MON, TUE, WED }
String key = "TUE";
Day day = ______;
Why: Every enum has a static valueOf(String) method. It returns the constant with that exact name.
12. What happens when Enum.valueOf() gets a name that does not match any constant?
Why:Enum.valueOf() throws an IllegalArgumentException if the name is not a valid constant.
13. Why should you handle IllegalArgumentException when you convert query keys to an enum manually?
Why: A user can send any key in the URL. If it is not a valid constant name, the conversion fails, so you should catch the error and return a clear message.
14. Why is it useful to use an enum type for a query parameter?
Why: An enum has a fixed list of constants, so only those values are accepted. This makes the handler method safer and easier to understand.