🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Exception Handling: all 10 questions

Quiz: Java Exception Handling · Question 5 of 10

What does try-with-resources guarantee?

What does try-with-resources guarantee?

  1. A.No exceptions will occur
  2. B.Resources declared in try(...) are closed automatically
  3. C.The program runs faster
  4. D.finally is not allowed
Answer & explanation

Correct answer: Resources declared in try(...) are closed automatically

Anything implementing AutoCloseable declared in try(...) is closed at the end.

Can you get the rest right without peeking?

Take the timed Quiz: Java Exception Handling quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →