Q. What is the purpose of the ‘finally’ block in exception handling?

A
To handle the exception
B
To execute code regardless of whether an exception occurs
C
To declare a new exception
D
To skip the exception
Solution:

The finally block executes cleanup code (e.g., closing resources) after try-catch, always.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!