Sample Code:1
public class ClassTest {
public static void main(String[] args) {
throw new java.lang.ArithmeticException();
}
}
----No compilation Error for above code, Compiler is not asking to handle the Exception
Sample Code:2
public class ClassTest {
public static void main(String[] args) {
throw new java.lang.Exception();
}
}
--Compiler wants to handle Exception using try-catch or throws.
can anyone explain this behavior of compiler.I think it is because we need to specifically mention the XYZException class(other than Exception class).