PROGRAM EXCEPTION HANDLING USING TRY AND CATCH BLOCKS

//PROGRAM TO IMPLEMENT EXCEPTION HANDLING USING TRY AND CATCH BLOCKS
class arithExcep
{
public static void main(String agrs[ ])
{
int a=10,b=0 ;
try
{
a=a/b;    // 10/0
System.out.println(“Don’t print”);
}
catch(ArithmeticException ae)
{
System.out.println(“Divide by zero”);
System.out.println(“Change the value of b”);
}
System.out.println(“Quit”);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *