1Z0-829 Handling Exceptions Practice Question
Which TWO statements about the try-with-resources statement are correct? (Choose two.)
⚠ Common exam trap
Many candidates think resources must be declared with the final keyword (Option B) or that finally blocks are prohibited (Option D), but the exam tests the exact JLS rules: resources are effectively final, and finally blocks are allowed but execute after resource closure.
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
✓
The resource class must implement AutoCloseable.
The try-with-resources statement requires that each resource implements the AutoCloseable interface (or its subinterface Closeable). This interface defines the close() method, which is automatically invoked by the JVM when the try block completes, ensuring proper resource management without explicit finally blocks.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The resource class must implement AutoCloseable.
Why this is correct
Correct: only AutoCloseable resources are allowed.
- ✗
The resource variable must be declared as final.
Why it's wrong here
It is effectively final, but explicit final is optional.
- ✓
Resources are closed in the reverse order of their declaration.
Why this is correct
Correct: resources are closed in reverse order.
- ✗
A try-with-resources statement cannot have a finally block.
Why it's wrong here
It can have a finally block.
- ✗
Resources are closed before the try block executes.
Why it's wrong here
They are closed after the try block completes.
Go deeper
Related to this question
About these practice questions
This 1Z0-829 question is part of Courseiva's 513-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 →
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.