Home  |   STIU  |   WOW  |   SCJP  |   SCDJWS   |   JEE FAQ  |   About US  |  

FAQ
  Java FAQ
  JSP FAQ
  Servlet FAQ
 

Advertisement

XyzWs Java FAQ:
Why it is not required to declare the Exception declared in the superclass' method when overriding it?


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend


Previous Next vertical dots separating previous/next from contents/index/pdf Contents
Advertisement
XyzWs Java FAQ: Why it is not required to declare the exceptions declared in the superclass' method when overriding it?

Why it is not required to declare the exceptions declared in the superclass' method when overriding it?


An implementation of a overriding method in a subclass may be totally different with its overridden method in the superclass. It may not have any exceptions needed to throw at all. The only restriction in Java compiler (8.4.6 Method Throws)is that the overriding method in subclass cannot be declared to throw border or new checked exceptions than the overridden method in the superclass (otherwise, you may break other codes because the runtime polymorphism).


Previous Next vertical dots separating previous/next from contents/index/pdf Contents

Support  | Feedback  | Help