Computer Science, asked by Anonymous, 1 year ago

What is multi-catch block in java?

Answers

Answered by EHSASS
3

★彡 Here is Your Answer 彡★

Java static block is the group of statements that gets executed when the class is loaded into memory by Java ClassLoader.

It is used to initialize static variables of the class. Mostly it’s used to create static resources when class is loaded.

Ehsass ★

Answered by rihanna50
1

java multi-catch block is used to perform different tasks at the occurrence of different exceptions.

EXAMPLE:

public class MultipleCatchBlock1 {  

 

   public static void main(String[] args) {  

         

          try{    

               int a[]=new int[5];    

               a[5]=30/0;    

              }    

              catch(ArithmeticException e)  

                 {  

                  System.out.println("Arithmetic Exception occurs");  

                 }    

              catch(ArrayIndexOutOfBoundsException e)  

                 {  

                  System.out.println("ArrayIndexOutOfBounds Exception occurs");  

                 }    

              catch(Exception e)  

                 {  

                  System.out.println("Parent Exception occurs");  

                 }              

              System.out.println("rest of the code");    

   }  

Similar questions