Re: Static methods overridden !!
- From: Lew <lew@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 25 Mar 2007 16:24:53 -0400
Ravi wrote:
Clearly saySomething comes from super class. This is confusing for
me.
The method-resolution mechanism moves up the inheritance hierarchy from the compile-time type to look for the first matching method at runtime. Since CowTest "is-an" AnimalTest, the invocation from CowTest can find the method in AnimalTest.
However, if CowTest did have a matching static method, it wouldn't override the superclass static method, it would hide the superclass static method. There is no polymorphism of static methods.
AnimalTest.saySomething() will never invoke CowTest.saySomething().
-- Lew
.
- References:
- Static methods overridden !!
- From: Ravi
- Re: Static methods overridden !!
- From: Daniel Pitts
- Re: Static methods overridden !!
- From: Ravi
- Re: Static methods overridden !!
- From: Eric Sosman
- Re: Static methods overridden !!
- From: Ravi
- Static methods overridden !!
- Prev by Date: Re: Class Libraries !! ?
- Next by Date: Re: Static methods overridden !!
- Previous by thread: Re: Static methods overridden !!
- Next by thread: Re: Static methods overridden !!
- Index(es):
Relevant Pages
|