Bird
0
0

Which annotation is commonly used inside a class annotated with @ControllerAdvice to handle exceptions?

easy📝 Conceptual Q2 of 15
Spring Boot - Exception Handling
Which annotation is commonly used inside a class annotated with @ControllerAdvice to handle exceptions?
A@Autowired
B@RequestMapping
C@ExceptionHandler
D@GetMapping
Step-by-Step Solution
Solution:
  1. Step 1: Identify exception handling annotation

    @ExceptionHandler is used to define methods that handle exceptions.
  2. Step 2: Exclude unrelated annotations

    @RequestMapping and @GetMapping define routes; @Autowired injects dependencies.
  3. Final Answer:

    @ExceptionHandler -> Option C
  4. Quick Check:

    Exception handling method annotation = @ExceptionHandler [OK]
Quick Trick: Exception handlers use @ExceptionHandler inside @ControllerAdvice [OK]
Common Mistakes:
  • Using @RequestMapping for exceptions
  • Confusing with @Autowired
  • Using @GetMapping incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes