Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
all events occur in real time
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
And remember: This way of calling a static method through an instance is allowed, but bad and confusing. My Eclipse environment sets up a warning if I do so, BTW.
Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
Originally posted by Rob Mech:
...let me summarize then to make sure I understand.
If a Static method is declared and redefined as in the first example in this thread. Any reference calls to it Dog.doStuff() or Animal.doStuff() call the doStuff() in the Animal class.
If I instance the object though, it calls the appropriate one so long as I reference the static method with the appropriate reference? ...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by Rob Mech:
If a Static method is declared and redefined as in the first example in this thread. Any reference calls to it Dog.doStuff() or Animal.doStuff() call the doStuff() in the Animal class.
Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
Originally posted by Rob Mech:
Now, my next big question here. How is this any different then overriding? Why the term "redefined"?
Originally posted by Keith Lynn:
When a method is overridden, then the invocation to be called is decided at runtime based on the runtime type of the caller.
When a method is hidden, then the invocation is decided based on the type of the reference.
Rob Mech, SCJP 1.5<br /><a href="http://www.robsprogrammingjunk.com/" target="_blank" rel="nofollow">http://www.robsprogrammingjunk.com/</a>
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |