Courseiva
Exception Handling and Development ToolseasyMultiple ChoiceObjective-mapped

1Z0-811 Exception Handling and Development Tools Practice Question

A developer needs to handle a specific checked exception, FileNotFoundException, but also wants to catch any other IOException that might occur. Which catch block ordering is correct?

⚠ Common exam trap

Watch out — candidates often think multi-catch can combine any exception types, but the compiler forbids combining a parent and child exception in the same multi-catch clause, and also forbids catching a parent before a child in separate catch blocks.

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 (FileNotFoundException e) first, then catch (IOException e).

Checked exceptions must be caught in order from most specific to most general. FileNotFoundException is a subclass of IOException, so it must be caught first; otherwise, the more specific catch block would be unreachable and cause a compilation error. This ordering ensures that the developer can handle the specific FileNotFoundException separately while still catching any other IOException in the second block.

Answer analysis

Option-by-option breakdown

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

  • Use a multi-catch: catch (FileNotFoundException | IOException e).

    Why it's wrong here

    Multi-catch is valid but does not demonstrate proper ordering because both exceptions are in the same catch block. It is not incorrect but does not answer the ordering question.

  • catch (IOException e) first, then catch (FileNotFoundException e).

    Why it's wrong here

    This will cause a compilation error because FileNotFoundException is a subclass of IOException and the first catch will catch all IOException, making the second unreachable.

  • catch (FileNotFoundException e) first, then catch (IOException e).

    Why this is correct

    This is correct because the more specific exception must be caught before the more general one.

  • Use a single catch (Exception e).

    Why it's wrong here

    This is too broad and catches all exceptions, not just IOExceptions.

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.