Exception
Hierarchy

Syntax
try
{
	//do something
}
catch (Exception1 e)
{
	//exception-handling statements
}
...
catch (ExceptionN e)
{
	//exception-handling statements
}
finally
{
	//statements
	//resource-release statements
}
			
Finally Block
public class E
{
	public static int quotient(int numerator, int denominator) throws ArithmeticException
	{
		return numerator/denominator;
	}

	public static void main(String args[])
	{
		try
		{
			quotient(10, 1);
		}
		catch (Exception e)
		{
			System.out.println(e.getClass().getName());
			System.out.println(e);
			System.out.println(e.getMessage());
			System.out.println(e.getStackTrace());
		}
		finally
		{
			System.out.println("Release resource ...");
		}
	}
}
			
Throws Clause
import java.io.*;

public class E
{
	public static void f1()
	{
		throw new ArithmeticException();//uncheck exception
	}

	public static void f2() throws IOException
	{
		throw new IOException();//checked exception
	}

	public static void main(String args[])
	{
		try
		{
			f1();
		}
		catch (Exception e)
		{
			System.out.println(e);
		}
		finally
		{
			System.out.println("Release resource ...");
		}

		try
		{
			f2();
		}
		catch (Exception e)
		{
			System.out.println(e);
		}
		finally
		{
			System.out.println("Release resource ...");
		}
	}
}
			
Create Exception
public class ExceptionADT extends Exception
{
	@Override
	public String getMessage()
	{
		Exception e = new Exception("Exception");
		return "ExceptionADT: "+e;
	}
}
			
public class E
{
	public static void main(String args[])
	{
		try
		{
			throw new ExceptionADT();
		}
		catch (ExceptionADT e)
		{
			System.out.println(e.getMessage());
		}
		finally
		{
			System.out.println("Release resource ...");
		}
	}
}
			
Reference