Courseiva
Handling ExceptionsmediumMultiple ChoiceObjective-mapped

1Z0-829 Handling Exceptions Practice Question

A company has a service layer with a method performOperation() that originally declared throws BaseException (a checked exception). Several client methods call performOperation() and catch BaseException, wrapping it in a RuntimeException for propagation. After a system upgrade, the implementation of performOperation() now explicitly throws two new checked exceptions: SubException1 and SubException2, both of which extend BaseException. The client methods must continue to compile without modifying their catch signatures, and they must still handle the new exceptions appropriately. What is the best way to modify the client methods?

⚠ Common exam trap

A common mix-up: candidates think they must explicitly catch new subclasses or use multi-catch, forgetting that a catch for the superclass already covers all subclasses due to polymorphism in exception handling.

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

No change needed because the catch for BaseException catches all subclasses.

In Java, a catch block for a superclass exception type (BaseException) will catch all subclasses (SubException1 and SubException2) due to polymorphism in exception handling. Since the client methods already catch BaseException and wrap it in a RuntimeException, no changes are needed to the catch signatures; the new exceptions are automatically handled. This satisfies the requirement that client methods continue to compile without modifying their catch signatures while still handling the new exceptions appropriately.

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 block to catch SubException1 and SubException2 and rethrow as RuntimeException.

    Why it's wrong here

    Unnecessary; existing catch already handles them and wraps in RuntimeException.

  • Modify the client method signature to declare throws SubException1, SubException2.

    Why it's wrong here

    Changes signature, affecting callers.

  • Add separate catch blocks for SubException1 and SubException2 before the existing BaseException catch.

    Why it's wrong here

    Unnecessary; existing catch already handles them.

  • No change needed because the catch for BaseException catches all subclasses.

    Why this is correct

    Polymorphism applies; no modification required.

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.