There are tons of rules.
http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8
Well, a normal use is a subclass method overriding the more general
method of its superclass with a method specific to that subclass. Is
this what you're referring to? It's not really a rule.
Mike Lewis
Grinnell College
> There is something about being more specific and general?
>
> what are those?
> There is something about being more specific and general?
>
> what are those?
The overriding method has to be able to handle every situation the
overridden method can handle, the the overriding method has to be usable in
every situation the overridden method could have been used.
Therefore, the parameters have to be of the same type, or of a more
general type (so that it can handle everything the old method could handle
and more), and the return value has to be of the same type, or a more
specific type (so that anything that could handle the old return value can
also handle the new one).
- Oliver
Sashi - 18 Jan 2006 16:15 GMT
> > There is something about being more specific and general?
> >
[quoted text clipped - 11 lines]
>
> - Oliver
Also, the overriding method should not throw exceptions that are more
general than the one in the parent class and also it should not throw
any exceptions not declared in the method in the parent class.
Sashi