Bird
0
0

What will happen if an exception is thrown in a Spring Boot controller but no matching @ExceptionHandler method exists in the @ControllerAdvice class?

medium📝 component behavior Q5 of 15
Spring Boot - Exception Handling
What will happen if an exception is thrown in a Spring Boot controller but no matching @ExceptionHandler method exists in the @ControllerAdvice class?
ASpring Boot returns a default error response with status 500
BThe application crashes without any response
CThe exception is ignored and the request succeeds
DThe exception is automatically logged but no response is sent
Step-by-Step Solution
Solution:
  1. Step 1: Understand exception handling fallback

    If no handler matches, Spring Boot uses its default error handling mechanism.
  2. Step 2: Default behavior of Spring Boot

    By default, Spring Boot returns a 500 Internal Server Error with a standard error body.
  3. Final Answer:

    Spring Boot returns a default error response with status 500 -> Option A
  4. Quick Check:

    No handler found = default 500 error response [OK]
Quick Trick: No handler means Spring Boot sends 500 error by default [OK]
Common Mistakes:
  • Thinking app crashes without response
  • Assuming exception is ignored
  • Believing no response is sent

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes