Courseiva
Question 40 of 513
Handling ExceptionshardMultiple ChoiceObjective-mapped

1Z0-829 Handling Exceptions Practice Question

A financial trading application uses Java 17 and processes millions of transactions per second. It uses a custom checked exception `TradeException extends Exception` for business rule violations. Recently, the transaction processing service began throwing a `RuntimeException` that wraps a `TradeException`, but the error logs only show the wrapper's message and stack trace, missing the original `TradeException` details. The logging framework prints the exception and its cause chain. The development team needs to ensure that the original `TradeException` message and stack trace are always logged. What is the most appropriate course of action?

⚠ Common exam trap

It's easy for candidates to think catching the wrapper and manually extracting the cause's message (Option A) is sufficient, but they overlook that the logging framework needs the full cause chain to print the original stack trace, not just the message string.

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

Modify the exception wrapping code to pass the original TradeException as a cause to the RuntimeException constructor.

Passing the original `TradeException` as the cause argument to the `RuntimeException` constructor (e.g., `new RuntimeException(message, cause)`) preserves the full cause chain. The logging framework, which prints the exception and its cause chain, will then output both the wrapper's stack trace and the original `TradeException`'s message and stack trace, ensuring complete visibility.

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 the RuntimeException in the main processing loop and print the cause's message using getCause().getMessage().

    Why it's wrong here

    This workaround does not fix the root cause and may miss other places where the exception is logged.

  • Modify the exception wrapping code to pass the original TradeException as a cause to the RuntimeException constructor.

    Why this is correct

    Using the cause constructor preserves the original exception in the cause chain.

  • Modify the TradeException class to extend RuntimeException.

    Why it's wrong here

    Changing the exception type may break existing method signatures that declare checked exceptions.

  • Override the getMessage() method in TradeException to return the original message.

    Why it's wrong here

    The wrapper's getMessage() is used, not the original's.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jul 4, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.