The overriding method can throw NO Exception, No new Checked Exception, Subclass of checked exception declared in overidden function and NEW UNCHECKED EXCEPTION.
In your case NullPointerException is an Unchecked Exception.
Hope it clarifies
And please use CODE tag in order to wrap your code examples for better visibility. Its a rule on the forum.
Cheers !!!
Dinesh Tahiliani wrote:
output : hi
Hello ranchers,
The above code complies and gives result as shown in output
How is this possible? interface is defining the method which has checked exception and when i am implementing in my class the same method but with different exception which is unchecked exception how its showing no error. Can you please tell what is happening here?
Whether i am overidding the method or overloading the method.
:?: