An example might help you. Look at the following piece of code
Now try calling these methods as follows
The output will be
As you can see, the non-static method obeys the
polymorphism rules. Though the reference is of Super type, the method is called on the Derived object. Overridding in work.
But on the other hand, the static method is called on the Super class, though it is redefined in the Derived class. This principle is called as hiding.
The static method in Derived class will be called only if you define the reference type as Derived -
The bottom line is,
The non-static methods in the parent class can be overridden by the child class. The static methods in the parent class can only be hidden or redefined by the child class, but cannot be overridden [ March 24, 2006: Message edited by: Mani Ram ]