• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem on Inheritance

 
Chaturaka Gunatilaka
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


When I executed the code,I got the output as Sub.myMethod 0.But I was expecting Sub.myMethod 200.What went wrong?Why am I wrong?Thank you.
 
Winston Gutkowski
Bartender
Pie
Posts: 10257
59
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chaturaka Gunatilaka wrote:When I executed the code,I got the output as Sub.myMethod 0. But I was expecting Sub.myMethod 200.What went wrong?Why am I wrong?

Won't tell you that, you need to ShowSomeEffort (←click); but I will ask you this:
What happens when new Sub() gets executed? EXACTLY. If you're not sure, look it up (you may find some useful stuff here) and write it down. Then apply it to your problem and see what you come up with.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic