✏️ Explanatory Question

What is the role of the finally clause in exception handling? Provide an example.

👁 66 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

The finally clause contains code that runs regardless of how the try block exits. Example:


try
{
    // Code that might throw exceptions
}
catch
{
    // Handle exceptions
}
finally
{
    // Clean-up code
}