Static method can not be overridden... Please some one tell me the reason why static method can not be overridden in subclass? I have lot of confusion in Static Method. I kmow they are the class methods but i am getting confuse at so many times... Please some one help...
static methods are known as class methods, overriding a method provides you run time polymorphism that is method selection at the run time on behalf of what object a reference variable is referring to. Static method are chosen at compile time on behalf of the reference variable. overriding never applies to static method because there is nothing like late binding or run time method selection.
One important fact: There is difference between overriding and redefining a method. What we did in the Animal Dog example was redefining eat() method in the subclass Dog. Overriding means, opening scope for run time polymorphism whereas redefining means just simply hiding the parent class method definition. Hope this helps!
With Regards, cmbhatt [ April 07, 2007: Message edited by: Chandra Bhatt ]