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
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: 7063
    
  16

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?
Artlicles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem on Inheritance
 
Similar Threads
Super in static
Strange recursive method call! ???
Overriding doubt ?
instance initializers
Invoking a Superclass Version of an Overridden Method