Very simple Static methods are not inherited by child class and hence cannot be overriden. Only instance methods are inherited by child class and therefore be overriden. think about why static methods are not inherited. Thanks Deepak
Then the parent has a static method, the Child cannot see it, so if no overriding rules are violated, the code would work fine. Here, if either static is over-ridden to non-static OR non-static is overridden to static, the compiler will complain. Else, both the static methods are correct in their own scope. And whenever the static method is called, during compilation only it is decided that it will be called using the reference method and not the object method it is referring to.
SCJP 5.0<br />IBM Rational Rose 633<br />Target SCWCD....
which static methods/variables and instance variables to be called are solely decided at complie time and not run time. For them the compiler only sees the "Class Type" of the reference variable used to invoke them. Dynamic method invocation is only for instance methods.
You donot override the static method/variables, but you simply hide them in your sub-classes. This is called shadowing of methods and variables. But even though you are hiding the static methods you still have to follow all the overriding rules.
And more importantly static method cannot be shadowed as non static method in SUb-Class and vice-versa...
I hope this explaination helps !!
"History would be kind to me, for I intend to write it."
This code shows static methods are not inherited because they are static
Error: The method iAmStaticMethod() is undefined for the type Child
Which static method to invoke is decided at compile time. Inheritance is only restricted to instance methods and not static methods. Static methods are @ class level and not at object level. Now since static methods are not inherited they cannot be overriden. Read Second Chapter in K&B [Static members] Thanks, Deepak