Multiple choice technology programming languages

How many finally{} blocks may there be in a try/catch structure?

  1. There must always be one, following the last catch{} block.

  2. There can be zero or one immediately after each catch{} block.

  3. There can be zero or one, following the last catch{} block.

  4. There can be any number, following the last catch{} block.

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

A try/catch structure can have either zero or one finally block, and if present, it must be placed after the last catch block. The finally block is optional but when used, there can only be one per try/catch structure. It cannot appear after each catch block individually, nor can there be multiple finally blocks. This ensures clean, predictable structure for cleanup code.