Thursday, April 11, 2019

throws Exception class

public class ExceptionThrow {
public static void main(String[] args) throws Exception {
try {
throw new Exception("Exception Caught in the Exception Super class and not in ExceptonA catch block");
}
catch (ExceptionA e) {
System.out.println("e.getMessage() " + e.getMessage());
}
}
}
class ExceptionA extends ExceptionB {
String s;
public ExceptionA(String s) {
super(s);
}
}
class ExceptionB extends Exception{
public ExceptionB(String s) {
super(s);
}
}

No comments:

Post a Comment