Skip to content
Sharp

Exceptions · interview question

How would you explain a common reason to use a 'finally' block in an interview?

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

Correct answer

A. To enforce resource cleanup

Why

A 'finally' block is commonly used to ensure that resources are released or cleaned up, such as closing files or releasing locks, regardless of whether an exception occurs.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →