Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

I forget: what is the rule for method overriding?

Thread view: 
puzzlecracker - 16 Jan 2006 02:08 GMT
There is something about being more specific and general?

what are those?
Danno - 16 Jan 2006 04:06 GMT
There are tons of rules.

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8
iamzeus@gmail.com - 17 Jan 2006 05:56 GMT
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?
Oliver Wong - 18 Jan 2006 15:35 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.