What will the following program print when run?.
public class Main{ public static void main (String [] args){ try{//from www.j av a2 s . com System.exit (0); } finally{ System.out.println ("finally is always executed !"); } } }
Select 1 option
Correct Option is : C
finally is always executed (even if you throw an exception in try or catch) but this is the exception to the rule.
When you call System.exit(...); The JVM exits so there is no way to execute the finally block.