Courseiva
Handling ExceptionsmediumMultiple ChoiceObjective-mapped

1Z0-829 Handling Exceptions Practice Question

Given the following code snippet inside a method:

try { // risky code

} catch (IOException | SQLException e) {

// handle

}

What is the implicit type of the exception variable 'e' in the catch block?

⚠ Common exam trap

The trap here is that candidates mistakenly think 'e' has a union type (like TypeScript) or that the compiler uses the first listed exception type, when in fact Java infers the most specific common superclass, which is Exception for IOException and SQLException.

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 of type Exception.

In Java, when a multi-catch clause catches multiple exception types (e.g., IOException | SQLException), the compiler infers the catch parameter's type as the closest common superclass that is not Object or Throwable. Since IOException and SQLException both extend Exception directly, the implicit type of 'e' is Exception. This allows the catch block to handle both exception types polymorphically.

Answer analysis

Option-by-option breakdown

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

  • It is of type Object.

    Why it's wrong here

    Too general; the compiler ensures it's an Exception subtype.

  • It is of type Exception.

    Why this is correct

    The common base of IOException and SQLException is Exception.

  • It is of type Throwable.

    Why it's wrong here

    Too general; exceptions are Throwable, but more specific is Exception.

  • It is either IOException or SQLException.

    Why it's wrong here

    The compiler treats it as the common superclass.

About these practice questions

One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.