JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class Program
{
public static void main(String[] args) {
try{
throwExceptionTest();
}
catch(ChildException ex){
System.out.println("Child");
}
catch(ParentException ex){
System.out.println("Parent");
}
}
private static void throwExceptionTest() throws ParentException{
throw new ChildException();
}
}
public class ParentException extends Exception{
}
public class ChildException extends ParentException{
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run