Problem Statement
Explain why try-with-resources is preferred for I/O and give two practical benefits.
Explanation
It guarantees timely, exception-safe closing of Closeable and AutoCloseable resources. Benefits: 1) Avoids leaks by closing even when exceptions occur. 2) Keeps code concise and readable; suppressed exceptions are preserved, aiding debugging.