You are pretty much right. The confusion will come in if you try to call one of the static methods from an instance (which is why you should always call from a Class). If you:
the method in ClassA will be called, but make one little change:
and the method in ClassB will be called. This is because the method is chosen at compile time based on the type of the reference not the type of the object. You will also get similar behaviour with non-static methods that are overloaded take a different type of parameter such as:
I hope I helped more than confused.
Joined: Oct 18, 2004
Thank you for the explaination it was indeed nice ......one small doubt are there any other occasions where the super class method will be hidden by the subclass methods ....or is it only when the method is a static method