✏️ Explanatory Question
int M = someValue;
try {
System.out.println("Entering try block");
if (M > 100)
throw new Exception(M + " is too large");
System.out.println("Exiting try block");
}
catch (Exception e) {
System.out.println("ERROR: " + e.getMessage());
}
Solution:
If someValue equals 1000, the condition (M > 100) becomes true, so an exception is thrown.
The control jumps directly to the catch block, skipping the line "Exiting try block".
Output:
Entering try block
ERROR: 1000 is too large