What will be the result of attempting to compile and run the following program?
public class Main{ public static void main (String args []){ Exception e = null; throw e; } }
Select 1 option
Correct Option is : A
You are throwing an exception and there is no try or catch block, or a throws clause.
So it will not compile.
If you do either put a try catch block or declare a throws clause for the method then it will throw a NullPointerException at run time because e is null.