Write a program to implement the concept of Exception Handling using predefined exception.

Program Code:
import java.lang.*;
class Exception_handle
{
public static void main(String argv[])
{
int a=10,b=5,c=5,x,y;
try
{
x=a/(b-c);
}
catch(ArithmeticException e)
{
System.out.println("DIVISION BY ZERO");
}
y=a/(b+c);
System.out.println("y="+y);
}
}

Output:
DIVISION BY ZERO
y=1
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: