Re: Static methods overridden !!



Thanks Eric for elaborate explanation on static method calls.

Will you accept an explanation that's not from the JVM
point of view, but from the Java language point of view?
Not a problem :)

Java calls the doit() method of the class
that matches the declared type of the `thing' reference.

Well, the class doesn't have the method at all ! Please refer the
original code again. CowTest class doesn't have saySomething method at
all . It has saySomething1 (1 (one) extra in the end, may be I should
have made this more clearly differentiating). I am not referring the
objects here and I am clear on the fact that objects have nothing to
do with invocation of static methods.

you can replace new CowTest().saySomething(); with
CowTest.saySomething(); if it makes things simpler.

Clearly saySomething comes from super class. This is confusing for
me.

Regards,
Ravi


.