Courseiva
Handling ExceptionsmediumMultiple ChoiceObjective-mapped

1Z0-829 Handling Exceptions Practice Question

Exhibit

Refer to the exhibit.

public class Main {
    public static void main(String[] args) {
        try {
            int result = 10 / 0;
        } catch (ArithmeticException e) {
            System.out.println("Arithmetic");
            throw e;
        } catch (Exception e) {
            System.out.println("Exception");
        } finally {
            System.out.println("Finally");
        }
    }
}

What is the output when the code is executed?

⚠ Common exam trap

The trap here is that candidates forget that a re-thrown exception produces a stack trace, or they mistakenly think the generic Exception catch block will execute after the specific one, leading them to choose Option B or C.

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

Arithmetic Finally [stack trace]

The code throws an ArithmeticException (division by zero) inside the try block, which is caught by the first catch block (ArithmeticException). The finally block always executes after the catch block, printing 'Finally'. The stack trace is printed because the exception is re-thrown in the catch block (implicitly or explicitly) and not handled, causing the program to terminate with an uncaught exception. The output shows 'Arithmetic', then 'Finally', followed by the stack trace.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Arithmetic Finally

    Why it's wrong here

    Incorrect: This would be the output if the exception were not rethrown after the catch block.

  • Arithmetic Exception Finally

    Why it's wrong here

    Incorrect: The second catch block is not reached because the exception is rethrown from the first catch.

  • Exception Finally

    Why it's wrong here

    Incorrect: The ArithmeticException is caught first, so 'Arithmetic' is printed, not 'Exception'.

  • Arithmetic Finally [stack trace]

    Why this is correct

    Correct: 'Arithmetic' is printed, then finally prints 'Finally', then the rethrown exception causes a stack trace.

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 →

How Courseiva writes practice questions · Editorial policy

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.