Skip to content
Sharp

SQL for Java Devs · interview question

How can you ensure that a ResultSet's resources are cleaned up even if an exception occurs during processing?

Multiple choiceHardchapter-8-curatedpremiumsql-for-java-devsresultsets-and-mapping
Choose one answer
Answer and explanation

Correct answer

D. Use a try-with-resources statement.

Why

Using a try-with-resources statement ensures that the ResultSet and other resources are closed automatically, even if an exception occurs. This is a clean and effective method for resource management.

Test yourself on SQL for Java Devs

A free test with instant, explained results. No account needed.

Start free test
All SQL for Java Devs questions →