Skip to content
Sharp

Exceptions · interview question

Why does a 'finally' block in Java exception handling matter in practice?

Multiple choiceEasychapter-6-curatedpremiumexceptionstry-catch-finally
Choose one answer
Answer and explanation

Correct answer

D. To execute code regardless of whether an exception is thrown or not

Why

The 'finally' block is executed after the try and catch blocks, regardless of whether an exception was thrown or not. It is commonly used for cleanup activities like closing resources.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →