File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confused" Watch "confused" New topic
Author

confused

kavita s. kumar
Greenhorn

Joined: Oct 26, 2001
Posts: 16
Hi
my question is
overridden method must not throw any exception which is not
thrown by overridden method
is it true..
i feel overriden method should not throw any checked exception which is not thrown by overridden method
i am right
thanks in advance
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
Originally posted by kavita s. kumar:
Hi
my question is
overridden method must not throw any exception which is not
thrown by overridden method
is it true..
i feel overriden method should not throw any checked exception which is not thrown by overridden method
i am right
thanks in advance


Kavitha
If you override a method
The overriding method must throw nuthing/same-exceptions/subclass of the exceptions thrown by the original method
HIH
Ragu
Cristian Negresco
Ranch Hand

Joined: Sep 15, 2001
Posts: 182
Hi Kavita,
I think you are right:

class A {
void m() {
System.out.println("A");
}
}
public class E extends A {
void m() throws ArrayIndexOutOfBoundsException {
System.out.println("B");
}
}
The class E compiles without problem.
So, the overriding method can throw any "unchecked" exceptions. Perhaps this is also one reason for which the some exceptions are "checked", becouse the compiler "checks" them.
..Cristian
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confused