A class must implement which interface to be used in a try-with-resources statement?
Correct answer
B. AutoCloseable
12 views
B. AutoCloseable
12 views
try-with-resources (Java 7+) calls close() automatically on any object that implements AutoCloseable (or its subinterface Closeable), even if an exception occurs.
Asked in: NTS, OCA Java, Technical Interviews
Not sure why the answer is B? Ask here and get an explanation.