Skip to content
Sharp

Exceptions · interview question

What role does the 'finally' block serve in Java exception handling?

Multiple choiceEasychapter-6-curatedpremiumexceptionsreliable-java-error-design
Choose one answer
Answer and explanation

Correct answer

A. It executes code that must run regardless of whether an exception was thrown.

Why

The 'finally' block is used to execute code that must run after a try-catch block, regardless of whether an exception is thrown or not. It's commonly used for resource clean-up tasks.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →