Author Topic:   Overriding Methods
J. Scott Smith
greenhorn
posted March 09, 2000 01:42 PM             
If you had the following in the super class:

public final amethod(){}

And in a subclass of the super class you had the following method:

public final amethod(){}

Would you be able to use the same final method verbatim without causing a compiler error? (I am aware that a final method cannot be overriden in a subclass, but can it be used as is in an overloaded capacity? I also understand that this is a strange question and probably would not come up in reality, but I am trying to learn all possible loopholes for this modifier.)

Also, what would happen if you tried to override a private method?

maha anna
bartender
posted March 09, 2000 01:56 PM             
Whenever you overload a method either in the same class or in one of its subclasses you CAN DO whatever you want with that new overloaded method. The overloaded method is a COMPLETELY NEW method which happened to have the same name as the other.

Regarding private methods , they are known ONLY to the class within which it is defined.The subclasses DO NOT EVEN know that such a method exists in one of their superclasses.

One more point is all private methods are implicitly final. Isn't it? But the vice versa is may/may not be true. (i.e) a final method may be declared as private/protected/public.
regds
maha anna

[This message has been edited by maha anna (edited March 09, 2000).]

J. Scott Smith
greenhorn
posted March 09, 2000 02:28 PM             
Thank you Maha Anna.

|