asked in Exception by (58.6k points)

1 Answer

/** Copyright (c), AnkitMittal JavaMadeSoEasy.com */
public class ExceptionTest {
    public static void main(String[] args) {
           
           try{
                  int i=10/0; //will throw ArithmeticException
           }catch(ArithmeticException ae){
                  System.out.println("Exception handled - ArithmeticException");
           }catch(RuntimeException re){
                  System.out.println("Exception handled - RuntimeException");
           }catch(Exception e){
                  System.out.println("Exception handled - Exception");
           }          
 
    }
}
 
/*OUTPUT
 
Exception handled - ArithmeticException
 
*/
answered by (58.6k points)

Java Interview Questions and Answers 2018

...