There are 3 exceptions that successively inherit Exception (Exception1 extends Exception, Exception2 extends Exception1, and Exception3 extends Exception2). In the program, you will find the public static void method1() throws Exception1, Exception2, Exception3 method. Task: write a catch block that will catch all three exceptions: Exception1, Exception2, and Exception3.
Catching a group of exceptions
- 3
Locked
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
OBINNA
7 June 2021, 04:52
Because Exception 2 and Exception 3 inherits Exception 1 which in turn inherits the Exception class..
So Exception 1 catches all exceptions.
0
Mateo
26 March 2019, 11:12
Solved it but can someone explain why
catches all 3 thrown Exceptions? 0
Roman
27 March 2019, 07:37
because inheritance )
+11