1. The way of handling exception is varied from exception to exception.
  2. For every exception type we should define corresponding catch blocks, hence try with multiple catch blocks is possible.
 try{
   risky code
}catch (ArithmeticException e ){
  //handler to A.E
}
catch (NullPointerException e){
  //handler for N.P.E
}
catch(IOException e){
  //handler for IOException
}
catch(Exception e){
 //handler for Exception
}

If try with multiple catch blocks present then the order of catch blocks are important.The order should be from child to parent other wise we will get compiler error saying Exception x has already been caught.

Example:Parent to Child

public class ExceptionDemo {

	public static void main(String[] args) {

		try{
			System.out.println(10 / 0);
		}catch (Exception ex) {

			ex.printStackTrace();

		}catch (ArithmeticException e){
			e.printStackTrace();
		}
	}
}
/*
Compile time error:
ExceptionDemo.java:11: exception java.lang.ArithmeticException has already been caught
                }catch (ArithmeticException e){
*/

Example:Child to Parent

public class ExceptionDemo {

	public static void main(String[] args) {

		try {
			System.out.println(10 / 0);
		} catch(ArithmeticException e) {
			System.out.println("ArithmeticException block");
		} catch(Exception ex) {
			System.out.println("Exception block");
		}
	}
}

/*
Output:
ArithmeticException block
*/

If there is no chance of raising an exception in try block then we can’t keep corresponding catch block otherwise we will get compile time error saying “exception is never thrown in the body of corresponding try statement“.But this rule is applicable only for fully checked exceptions.

Example:1

import java.io.IOException;
public class ExceptionDemo {

	public static void main(String[] args) {

		try{
			System.out.println("Hello");
		}catch (IOException ex) {
			ex.printStackTrace();
		}
	}
}
/*
Compile time error:
ExceptionDemo.java:8: exception java.io.IOException is never thrown 
in body of corresponding try statement
                }catch (IOException ex) {
*/

Note:IOException is fully checked exception.

Example:2

public class ExceptionDemo {

	public static void main(String[] args) {

		try {
			System.out.println("Java2Learn");
		} catch(Exception e) {
			System.out.println("Exception block");
		} 
	}
}
/*
Output:
Java2Learn
*/