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
Post A Comment:
0 comments: