java program 5:

java program 5:
WAP to catch any 3 built in exceptions in java.

class exception
{
public static void main(String args[])
{
try
{
int a=args.length;
System.out.println("a="+a);
int b=42/a;
try
{
int c[]={1};
c[42]=99;
}
catch(ArrayIndexOutOfBoundsException e)
{System.out.println("Arrays index oob"+ e);
}
}
catch(ArithmeticException e )
{
System.out.println("divide by 0"+e);
}


catch(ArrayStoreException e)


{
System.out.println("Wrong data type");
}catch(Exception e)
{
System.out.println("recaught"+ e);
}
}
}

Comments

Popular posts from this blog

REFLECTION OF A TRIANGLE (COMPUTER GRAPHICS)