Design and Develop a java program using try and catch.

Program Code:
import java.io.*;
Class TryDemo
{
public static void main(String args[])
{
int a,d,b=10;
try
{
a=0;
d=b/a;
System.out.println (“this is an exception”);
}
catch (ArithmeticException e)
{
System.out.println (“ArithmeticException”);
}
System.out.println (“THIS IS AFTER CATCH BLOCK”);
}
}

Output:
Arithmetic Exception THIS IS AFTER CATCH BLOCK
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: