I think you are expecting to overriding take place and produce different output, remember overriding is applicable to "objects", static methods are class level.
SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
ramesh maredu wrote:I think you are expecting to overriding take place and produce different output, remember overriding is applicable to "objects", static methods are class level.
I know that., this is the example of the SCJP by kathy . but why the output is a a a ?
It must be a d a .!
Because it is static method, overriding doesn't take place, when you say a.doStuff(), because doStuff() is static method compiler replaces reference with class name, so here after compiling code will be A.doStuff(), so it invokes A version of doStuff().
SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.