aspose file tools*
The moose likes Beginning Java and the fly likes Problem on Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem on Inheritance" Watch "Problem on Inheritance" New topic
Author

Problem on Inheritance

Chaturaka Gunatilaka
Greenhorn

Joined: Oct 06, 2012
Posts: 16


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

Joined: Mar 17, 2011
Posts: 8008
    
  22

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

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem on Inheritance