Question 22 of 513
1Z0-829 Java I/O API and Securing Applications Practice Question
Which TWO are true about the try-with-resources statement?
⚠ Common exam trap
Oracle often tests the distinction between Closeable and AutoCloseable, and the requirement that resources must be declared inside the try parentheses (pre-Java 9) or be effectively final (Java 9+), leading candidates to incorrectly think resources must always be declared inside the try block or that Closeable is the only valid interface.
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
✓
Resources declared outside the try block can be used if they are effectively final.
The try-with-resources statement allows resources declared outside the try block to be used, provided they are effectively final (i.e., their reference does not change after initialization). This was introduced in Java 9, which enhanced try-with-resources to support effectively final variables in addition to those declared directly within the try parentheses.
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 declared outside the try block can be used if they are effectively final.
Why this is correct
Effectively final variables can be used as resources.
- ✗
All resources must be of the same type.
Why it's wrong here
They can be of different types.
- ✓
Resources declared in try-with-resources are implicitly final.
Why this is correct
They cannot be reassigned within the block.
- ✗
Multiple resources must be separated by commas.
Why it's wrong here
They are separated by semicolons, not commas.
- ✗
The resource must implement the Closeable interface.
Why it's wrong here
It must implement AutoCloseable, which Closeable extends, but AutoCloseable is sufficient.
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 →
Last reviewed: Jun 30, 2026
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.
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.
Sign in to join the discussion.