What will be the output of below multiple catch statements and what will be the output when we reverse order of all catch statements?

In below code ArithmeticException is a class which extends RuntimeException and RuntimeException is a class which extends Exception.

package testjava.exceptionhandling;

public class ExceptionOrder 
{
	public static void main(String args[])
	{
		int a = 10;
		try
		{
			a = a / 0;
		}
		
		catch(ArithmeticException ae)
		{
			System.out.println("Arithmetic Exception");
		}
		catch(RuntimeException re)
		{
			System.out.println("Runtime Exception");
		}
		catch(Exception e)
		{
			System.out.println("Exception");
		}		
	}
}

Above code will output : Arithmetic Exception. If you will change order of catch statement like below

package testjava.exceptionhandling;

public class ExceptionOrder 
{
	public static void main(String args[])
	{
		int a = 10;
		try
		{
			a = a / 0;
		}
		
		catch(Exception e)
		{
			System.out.println("Exception");
		}
		catch(RuntimeException re)
		{
			System.out.println("Runtime Exception");
		}
		catch(ArithmeticException ae)
		{
			System.out.println("Arithmetic Exception");
		}			
	}
}

After changing the order. You will get "Unreachable catch block for RuntimeException. It is already handled by the catch block for Exception" for RuntimeException catch block.

For ArithmeticException block you will get error "Unreachable catch block for ArithmeticException. It is already handled by the catch block for RuntimeException." 

compiler will ask you to remove both RuntimeException and ArithmeticException block because exception is already handled by Exception class.