What is the purpose of the 'finally' block in exception handling?

What is the purpose of the 'finally' block in exception handling?

Approach: Explain code that runs regardless of error.

A block that is executed after 'try' and 'catch' blocks, regardless of whether an exception was thrown or caught. Often used for cleanup like closing files.

Follow-up: Will finally run if the system calls exit() in the try block?

Key concepts: resource cleanup.