Practical 20


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

JAVA Code :-

Import java.lang.*;
class ThrowsDemo
{
            static void throwOne() throws IllegalAccessException         {
                        System.out.println("Inside throwOne.");
                        throw new IllegalAccessException("demo");
            }         
            public static void main(String args[])
            {
                        try {
                                    throwOne();
                        }
                        catch(IllegalAccessException e) {
                                    System.out.println("Caught " + e);
                        }
            }
}

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