Catching a group of exceptions

  • 3
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.
You can't complete this task, because you're not signed in.
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Mateo
Level 26, Zagreb, Croatia
26 March 2019, 11:12
Solved it but can someone explain why
catch (Exception1 e){ }
catches all 3 thrown Exceptions?
Roman
Level 41
27 March 2019, 07:37
because inheritance )