package net.dharmaraj;
public class ThrowsDemo
{
static void throwMethod() throws Exception
{
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.IllegalAccessException: demo
No comments:
Post a Comment