1. Home
  2. Computer Science MCQs
  3. JAVA
  4. A class must implement which interface to be used in a…

Added 2 Nov 2026

A class must implement which interface to be used in a try-with-resources statement?

  1. Iterable
  2. AutoCloseable Correct answer
  3. Runnable
  4. Serializable

Correct answer

B. AutoCloseable

12 views

MCQSEXAM

Explanation

try-with-resources (Java 7+) calls close() automatically on any object that implements AutoCloseable (or its subinterface Closeable), even if an exception occurs.

Reference

Asked in: NTS, OCA Java, Technical Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More JAVA MCQs

Practise all JAVA MCQs

Similar MCQs