Multiple choice technology programming languages

What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?

  1. This is not legal, so the program will not compile.

  2. The method throws the exception to its caller, exactly if there were no try{} block.

  3. The program halts immediately.

  4. The program ignores the exception.

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

If an exception is thrown inside a try block and no matching catch block is found in the current method, the exception propagates up the call stack to the calling method, behaving as if no try block existed.