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