Question 178 of 513
Creating Custom Exceptions in Java
Which TWO statements about creating custom exceptions are correct? (Choose two.)
Quick Answer
Calling super(cause) inside a custom exception's constructor is correct because that call forwards the cause straight to Throwable's own constructor, and Throwable is built specifically to store whatever cause it is given and expose it later through getCause(), so you do not need to write any additional code to wire that up yourself. This is the mechanism that underlies exception chaining: instead of only reporting that something failed, your custom exception can preserve the original lower-level exception that triggered it, so anyone debugging later can trace the full cause-and-effect chain rather than seeing just the outermost symptom. It is also why the best practice of giving custom exceptions a constructor that accepts both a message and a cause matters so much: the message lets you describe what went wrong in terms meaningful to your application, while the cause preserves the underlying technical failure for logging and debugging, and calling super with the cause is what actually connects your custom exception into that chain rather than just extending Throwable in name only. On the exam, whenever a question centers on custom exceptions and mentions passing a cause into a super constructor call, recognize that the heavy lifting is already handled by Throwable itself; your job as the subclass author is simply to call the right super constructor and expose sensible constructors to callers.
⚠ Common exam trap
Watch out — candidates often confuse the requirement to extend Throwable (or a subclass) with implementing a nonexistent Exception interface, or they mistakenly think that custom exceptions must be declared final to prevent misuse, when in fact Java allows and encourages subclassing of custom exceptions for more granular error handling.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
It is good practice to provide a constructor that takes a String message and a Throwable cause.
It is a well-established best practice in Java to provide a constructor that accepts both a String message and a Throwable cause, enabling precise error reporting and chaining of exceptions. This allows developers to pass a human-readable description along with the underlying cause, which is essential for debugging and logging.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Custom exceptions should extend Error to indicate fatal errors.
Why it's wrong here
Error is not for application exceptions.
- ✗
Custom exception classes should be declared final to prevent subclassing.
Why it's wrong here
Not required or recommended.
- ✗
Custom exceptions must implement the Exception interface.
Why it's wrong here
Exception is a class, not interface.
- ✓
It is good practice to provide a constructor that takes a String message and a Throwable cause.
Why this is correct
Common to have such constructor.
- ✓
When calling super(cause) in a custom exception constructor, the cause is automatically set.
Why this is correct
Throwable constructor does that.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on 1Z0-829
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Given the code in the exhibit, which of the following is true about this custom exception?
easy- A.It cannot be used with multi-catch because it is unchecked.
- ✓ B.It is an unchecked exception.
- C.It must be caught or declared in the method signature.
- D.It must implement the Serializable interface.
Why B: The custom exception extends RuntimeException, which makes it an unchecked exception. Unchecked exceptions do not require handling or declaration in the method signature, and they can be used in multi-catch blocks.
Last reviewed: Jun 25, 2026
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.