Multiple choice technology programming languages

Identify whether the following statement is true or false.
The finally block is executed when an exception is thrown, even if no catch matches it.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The finally block always executes when an exception is thrown, regardless of whether a catch block handles it. This is guaranteed behavior except in extreme cases like System.exit() or JVM crash. It ensures cleanup code runs.

AI explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) True - This option is correct because the finally block is executed when an exception is thrown, even if no catch matches it. The finally block is a block of code that is always executed, regardless of whether an exception is thrown or not.

Option B) False - This option is incorrect because the statement is actually true. The finally block is executed when an exception is thrown, even if no catch matches it.

The correct answer is A. The finally block is executed when an exception is thrown, even if no catch matches it.