Basically, the concept is of
polymorphism. Overriding is just a way to achieve it.
Base b = new SubClass();
b.m1(); //here subclass's m1() should be called as the actual object is of class SubClass.
Now, static methods and fields do not take part in polymorphism.
ie. Base.sm1(); will call Base's static method and SubClass.sm1() will call SubClass's static method (as you would expect). But the interesting point is b.sm1() will call Base's method even though the object is of class SubClass. That's why it is said that static methods are not overidden but are hidden.
Hidden means you can go behind the curtain and can access the hidden thing. Ex.
SubClass s = new SubClass();
s.sm1(); // will call SubClass's static method.
s.m1(); // will call SubClass's instance method.
( (Base) s ).sm1(); // will call base's static method.
( (Base) s ).m1(); // will STILL call Subclass's instance method. There is no going behind the curtains!
HTH,
Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new
Pattern)
www.enthuware.com/jqplus