Courseiva
Handling ExceptionsmediumMultiple SelectObjective-mapped

1Z0-829 Handling Exceptions Practice Question

Which TWO statements about try-with-resources are true? (Choose two.)

⚠ Common exam trap

Watch out — candidates often assume resources close in declaration order (A) or that only one resource is allowed (C), but the exam tests the reverse close order and the ability to manage multiple resources, as well as the precise timing of resource closure relative to 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

If both the try block and the close method throw exceptions, the close exception is suppressed.

When both the try block and the close method throw exceptions, the exception from the close method is suppressed and added to the suppressed exceptions list of the exception thrown by the try block. This behavior is defined by the try-with-resources specification in Java, ensuring that the primary exception is not masked by resource-closing exceptions.

Answer analysis

Option-by-option breakdown

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

  • Resources are closed in the order they are declared.

    Why it's wrong here

    Closed in reverse order.

  • If both the try block and the close method throw exceptions, the close exception is suppressed.

    Why this is correct

    Suppressed exception mechanism.

  • Only a single resource can be managed in a try-with-resources statement.

    Why it's wrong here

    Multiple resources can be declared.

  • Resources must implement AutoCloseable.

    Why this is correct

    Required for try-with-resources.

  • Resources are closed after the catch block if an exception occurs.

    Why it's wrong here

    Resources are closed before any catch block.

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.