Bird
0
0

Which class should a custom unchecked exception extend in Spring Boot?

easy📝 Conceptual Q2 of 15
Spring Boot - Exception Handling
Which class should a custom unchecked exception extend in Spring Boot?
Ajava.lang.Exception
Bjava.lang.Error
Cjava.lang.RuntimeException
Djava.lang.Throwable
Step-by-Step Solution
Solution:
  1. Step 1: Recall exception hierarchy

    Checked exceptions extend Exception; unchecked exceptions extend RuntimeException.
  2. Step 2: Identify unchecked exception base

    For custom unchecked exceptions, extend RuntimeException to avoid mandatory try-catch.
  3. Final Answer:

    java.lang.RuntimeException -> Option C
  4. Quick Check:

    Unchecked exceptions extend RuntimeException [OK]
Quick Trick: Unchecked exceptions extend RuntimeException, not Exception [OK]
Common Mistakes:
  • Extending Exception causes checked exception behavior
  • Extending Error is for serious JVM errors, not custom exceptions
  • Extending Throwable is too general and not recommended

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes