1Z0-829 Handling Exceptions Practice Question
Exhibit
Refer to the exhibit.
```
public class ExceptionDemo {
public static void main(String[] args) {
try {
throw new RuntimeException("A");
} catch (RuntimeException e) {
throw new RuntimeException("B");
} finally {
throw new RuntimeException("C");
}
}
}
```What is the result when the main method is executed?
⚠ Common exam trap
The trap here is that candidates often mistakenly think that the finally block always prints something or that the catch block for a broader exception (like Exception) will execute, but the specific exception type (ArithmeticException) is matched first, and the finally block does not alter the flow unless it contains a return or throw statement.
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
✓
C is printed and the program terminates.
The question stem does not include the program code; therefore, the result cannot be determined.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Both B and C are printed and the program terminates.
Why it's wrong here
Incorrect. The try block throws an exception before executing the print statement for 'A', so 'A' is never printed. The exception is caught by the ArithmeticException handler, which prints 'C'.
- ✗
B is printed and the program terminates.
Why it's wrong here
Incorrect. The ArithmeticException is caught by its specific handler (prints 'C'), not by the broader Exception handler (which would print 'B'). Therefore, 'B' is not printed.
- ✓
C is printed and the program terminates.
Why this is correct
Correct. The try block throws an ArithmeticException, which is caught by the catch (ArithmeticException e) block, printing 'C'. The finally block executes but does not throw an exception, so the program terminates normally after printing 'C'.
- ✗
A is printed and the program terminates.
Why it's wrong here
Not among the original choices; it was listed as 'D: A is printed and the program terminates.' This is incorrect because the exception prevents the print of 'A'.
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.