at Testp.doit(Testp.java:14) at Testp.main(Testp.java:23)
********************* Scenario 2
output : hi
I have override the metho doit() in both scenario. As far i know that if superclass decalres the Exception , the n subclass must or not delcare the exception. If it declares then it should declare the subtype of exception.
Here in these 2 scenarios my subclass declares the exception, Scenario 1 throws me the runtime/complie error. Scenario2 doesn't throws any exception.
Please explain i am getting confused..
posted 8 years ago
subclass must declare exception or sublass of this exception .... but this is only true for checked exceptions (exceptions that derive from Exception but not from RuntimeException). RuntimeException and it's derivates are 'unchecked exceptions'. Method may declare unchecked exception, but compiler doesn't care about it. Error and Throwable are unchecked too.
[ June 23, 2008: Message edited by: Ireneusz Kordal ] [ June 23, 2008: Message edited by: Ireneusz Kordal ]
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads