Super is the output. That means, instance/static variables do not participate in Polymorphism.
bhanu chowdary wrote:overriding is only for methods and not variables. The FOO variable in your Sub hides the FOO in Super. try this and see what it is printing.
That is correct. Static methods/variables only look at the reference type not the runtime type. Therefore is it's advisable to access static methods/variables with the classname and not with a reference type. Because otherwise when you change the referencetype you can invoke other methods.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Saibabaa Pragada wrote:Super is the output. That means, instance/static variables do not participate in Polymorphism.
same is the case with static methods because eventhough you call a static metho with a reference variable, at runtime it will be classname.staticmethodname. please Write a sample code for this and check.
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
a bit of art, as a gift, the permaculture playing cards