This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about sub class

 
John Batista
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my code:

the root class


the node class


the main class


In the screenshot, the x is from the node class, while name() that's run belongs to the root class. what is this inconsistency? Thanks
 
John Batista
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, never mind. after googling, apparently just have to live with that. That's the rule. nothing can be done about it. Thanks
 
Vishwanath Krishnamurthi
Ranch Hand
Posts: 331
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

Overriding is only for methods. Not for instance fields.

PS: You might find it easier to paste the code and use code tags, than to post screenshots
 
Pranav Raulkar
Ranch Hand
Posts: 73
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
Similar question has been asked recently by a fellow java rancher. Refer to this post http://www.coderanch.com/t/539683/java/java/inheritance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic