Multiple choice technology programming languages

Which of the following options is true for the following program: try { if (choice) { while (true) } else { system .exit(1): } }finally { codetocleanup(); }

  1. Runtime Exception

  2. finally block will be executed

  3. finally block will not be executed

  4. Compilation error in else block

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

When System.exit(1) is called in the else block, the JVM terminates immediately. The finally block is NOT executed because System.exit() bypasses all normal termination logic. This is a key exception to the rule that finally blocks always execute - System.exit() is one of the rare cases where finally is skipped.