Bird
0
0

Which Java class should a custom checked exception extend?

easy📝 Conceptual Q2 of 15
Java - Custom Exceptions
Which Java class should a custom checked exception extend?
AException
BRuntimeException
CError
DThrowable
Step-by-Step Solution
Solution:
  1. Step 1: Recall checked vs unchecked exceptions

    Checked exceptions must be declared or handled and extend Exception but not RuntimeException.
  2. Step 2: Identify correct superclass for checked exceptions

    Exception is the base class for checked exceptions; RuntimeException is for unchecked.
  3. Final Answer:

    Exception -> Option A
  4. Quick Check:

    Checked exception base class = Exception [OK]
Quick Trick: Checked exceptions extend Exception, unchecked extend RuntimeException [OK]
Common Mistakes:
  • Extending RuntimeException for checked exceptions
  • Extending Error which is for serious JVM errors
  • Extending Throwable directly without reason

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes