1Z0-829 Handling Exceptions Practice Question
Given an exception chain where a custom exception is created with a cause, which method is used to set the cause after construction?
⚠ Common exam trap
It's easy for candidates to confuse `initCause(Throwable)` with `addSuppressed(Throwable)`, or assume the cause can only be set via constructor, missing the post-construction capability that `initCause` provides.
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
✓
initCause(Throwable)
`initCause(Throwable)` is the method provided by the `Throwable` class to set the cause of an exception after the exception has been constructed. This is useful when the exception must be created without a cause (e.g., via a no-arg constructor) and the cause is determined later. The cause can only be set once; a second call will throw an `IllegalStateException`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The cause can only be set via constructor.
Why it's wrong here
initCause can be used after construction.
- ✗
setCause(Throwable)
Why it's wrong here
No such method in Throwable.
- ✗
addSuppressed(Throwable)
Why it's wrong here
Used for suppressed exceptions, not cause.
- ✓
initCause(Throwable)
Why this is correct
Allows setting the cause after construction.
Go deeper
Related to this question
About these practice questions
This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.