static fields and inheritance

Hi All,

I have simple question.

Say I have super class X and a static method named show.

Now I have sub class Y that extends X and also overrides the method show.

Next I creat object of type X

Y y = new Y....

X x = y;

x.show() calss to the static method of X not that of Y!. why? I mean according to polymorphism the method that should be called is that of y because x actually references to its subclass

Thank u in advance

Eyal

[489 byte] By [Eyal2007a] at [2007-11-27 9:14:37]
# 1
Static methods are not overriden. http://faq.javaranch.com/view?OverridingVsHiding
aniseeda at 2007-7-12 22:02:57 > top of Java-index,Java Essentials,New To Java...
# 2
According to inheritance, only instance methods and variables are inherited. Static members wont belong to instances, they belong to class.
swatcata at 2007-7-12 22:02:57 > top of Java-index,Java Essentials,New To Java...