Intermediate
Java
Q100 / 100
What is the try-with-resources statement?
Correct! Well done.
Incorrect.
The correct answer is B) A try block that automatically closes AutoCloseable resources declared in its header when the block exits
B
Correct Answer
A try block that automatically closes AutoCloseable resources declared in its header when the block exits
Explanation
try (InputStream in = new FileInputStream(f)) { } automatically calls in.close() on exit, equivalent to a manual finally block but more concise and correct.
Progress
100/100