India's Largest Free Online Education Platform

Exception handling program in java

Exception handling program in java

Code:

public class Exception_Handling 
{
    public static void main(String args[])
    {
        int a = 11, b = 7, c = 7, x, y;
        try
           {
            x = a/(b-c);
           }
        catch (ArithmeticException e)
           {
            System.out.println("Divide by zero Error");
           }
        y=a/(b+c);
          { 
              System.out.println("y= " +y);
          }
     }
}

Output:

Leave a Reply

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

error: Content is protected !!