What is the result when you compile and run the following code?
public class ThrowsDemo {
static void throwMethod() {
System.out.println("Inside throwMethod()");
throw new IllegalAccessException("demo");
}
public static void main(
String args[]) {
try {
throwMethod();
} catch (IllegalAccessException e) {
System.out.println("Caught " + e);
}
}
}--------------------------------------------------------------------------------
A) Compilation error
B) Runtime error
C) Compile successfully, nothing is printed.
D) Inside throwMethod. followed by caught:
java.lang.IllegalAccessExcption: demo
The result given is A but i feel it should be D
any comments...