Aim:- Write a simple program to
show how Exception Handling works in java.
JAVA Code :-
import java.lang.*;
class Excep
{
public static void main(String[] args) {
int
a=50,b=0,ans;
try{
ans=a/b;
}
catch(ArithmeticException
e) {
System.out.println("Can't Divide by
zero: " +e);
}
finally
{
System.out.println("Program
ends....");
}
}
}
Output:-
No comments:
Post a Comment