Spring Validation and Exception Handling

Test your grasp of validation frameworks and global exception handling.

1. Which annotation is used to trigger validation of a request body in Spring MVC?
2. Select all valid JSR-380 validation annotations (used for field-level constraints).
3. Spring's @ControllerAdvice annotation is used to handle exceptions globally across multiple controllers.
4. What is the full class name (without package) of the exception thrown when request body validation fails in Spring (e.g., missing @NotNull field)?
5. Which annotation is used to enable validation for controller method parameters (e.g., path variables, request parameters) at the class level in Spring?
6. Which of the following are valid approaches to handle exceptions in Spring MVC?
7. The @Size validation annotation can only be applied to String fields.
8. What attribute is used within validation annotations (e.g., @NotNull, @Size) to specify a custom error message?
9. Which interface must be implemented to create a custom validation constraint in Spring?
10. Which of the following are valid return types for a method annotated with @ExceptionHandler?
Answered 0 of 0 — 0 correct