output : Exception in thread "main" java.lang.Error: Unresolved compilation problem: Exception IOException is not compatible with throws clause in Test1.doit()
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.
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 ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com