Practical 18


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

Programs

Home Aim:- Write a program to convert rupees to dollar. (60rupees=1 dollar). Aim:- Write a program that calculate percentage marks...