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 ...");
}
}
}
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 ...");
}
}
}
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 ...");
}
}
}