Wednesday, August 7, 2013

JAVA Program to Handle In-built Exceptions

Program to Handle any Three In-built Exceptions
class checkExcept
{
public void add()
{
try
{
int y = 20,z = 0;
int x = y/z;
System.out.println(x);
System.out.println("working");
}
catch(ArithmeticException a)
{
System.out.println("error");
}
catch(SecurityException a2)
{
System.out.println("error");
}
catch(ArrayStoreException a1)
{ }
catch(Exception x)
{
System.out.println(x.getMessage());
}
finally
{
System.out.println("finaly");
}
}

public static void main(String a[])
{
checkExcept c = new checkExcept();
c.add();
}
}


No comments:

Post a Comment