Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inheritance problem

 
ajithsasi kumar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


the names are displayed as null in the display method of the main class. Why it is not possible to get the values. Sir Help me...
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make a slight change:


You were using the overrided version of the name in class B. You had to take the name of the Class A only.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sandeep
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I said:

You were using the overrided version of the name in class B

Actually you were hiding the field 'name' in your class B. Pardon me for saying 'Overriding'.
 
ajithsasi kumar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You 'Sandeep Mukherji' for your reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic