Practical 19


Aim:- Show the implementation of ‘throw’ keyword.

JAVA Code :-

import java.lang.*;

class ThrowDemo
{
   static void demo()
   {
            try
            {
               throw new NullPointerException("demo");
            }

            catch(NullPointerException e)
            {
                System.out.println("Caught inside demo...");
                throw e;
            }
     }

     public static void main(String[] args)
     {
            try
            {
              demo();
            }
           
            catch(NullPointerException e)
            {
                System.out.println("Recaught...");    
            }
      }
}

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...