Courseiva
Exception Handling and Development ToolseasyMultiple ChoiceObjective-mapped

1Z0-811 Exception Handling and Development Tools Practice Question

A developer writes a catch block that handles multiple exception types that have a subclass relationship. Which of the following is a valid use of the multi-catch feature?

⚠ Common exam trap

The 1Z0-811 exam often tests the rule that multi-catch cannot contain exception types with a subclass relationship, and that separate catch blocks must order exceptions from most specific to most general to avoid unreachable code.

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

catch (IOException e) { ... } catch (SomeOtherUnrelatedException e) { ... }

It demonstrates the proper use of separate catch blocks for unrelated exception types, which is valid. The multi-catch feature (introduced in Java 7) allows catching multiple exception types in a single catch block only if they are not in a parent-child relationship; otherwise, the compiler reports an error due to unreachable code. Since IOException and SomeOtherUnrelatedException are unrelated, separate catch blocks are perfectly valid.

Answer analysis

Option-by-option breakdown

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

  • catch (IOException | FileNotFoundException e) { ... }

    Why it's wrong here

    Multi-catch cannot contain exceptions where one is a subclass of another; compile error.

  • catch (IOException e) { ... } catch (SomeOtherUnrelatedException e) { ... }

    Why this is correct

    Separate catches are allowed; the more specific exception (if needed) should come first, but if they are unrelated, order doesn't matter. This approach is valid.

  • catch (FileNotFoundException | IOException e) { ... }

    Why it's wrong here

    Same as B, order doesn't matter; still a compile error.

  • catch (IOException e) { ... } catch (FileNotFoundException e) { ... }

    Why it's wrong here

    FileNotFoundException is a subclass of IOException; the first catch would catch it, making the second unreachable.

About these practice questions

This 1Z0-811 question is part of Courseiva's 481-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-811 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-811 exam.