Multiple choice

If we want to write a statement that processes irrespective of whether the program has an exception or not, it should be written inside the ___ block.

  1. try

  2. else

  3. catch

  4. if

  5. finally

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

The finally block contains the code that we want to run irrespective of whether the try block contains an exception or not. If the try block has an exception the control will move from the try block to the catch block and then to the finally block. If there is no exception the control will move directly from the try block to the finally block.