Thread: Dynamic Binding
View Single Post
  #2 (permalink)  
Old 04-09-2008, 11:32 AM
Eranga's Avatar
Eranga Eranga is offline
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,039
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
How did you get that output. There should be a filed hiding. You use the same filed name on Sub and Super classes and use the same variable name. If you are working on a Java IDE you should notice it.

So, since you use the sup object reference with the Super class you definitely get the result is 100. It never refer the variable a of the class Sub.

Hope it's clear to you.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote