PROGRAM-
class ExceptionDem4
{
public
static void main(String args[ ])
{
System.out.println("In the Main
block");
try
{
System.out.println("In the try
block");
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
int c;
c=a/b;
System.out.println("Result="+c);
}
catch(ArrayIndexOutOfBoundsException ie)
{
System.out.println("Invalid
Index");
}
catch(ArithmeticException ae)
{
System.out.println("Divide
By zero");
}
finally
{
System.out.println("Always
execute");
}
}
}
Comments
Post a Comment