This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes questions about method overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "questions about method overriding" Watch "questions about method overriding" New topic
Author

questions about method overriding

Chrix Wu
Ranch Hand

Joined: Nov 15, 2009
Posts: 121
Say I have Class A as super class, and it has method "caller()" which uses "callee()"

Then I have Class B inherits from A, and now I rewrites "callee()", and in the drived class version of "caller()", simple calls "super.caller()"

When Object B's caller() is invoked, is the new version of callee() going to be invoked too?



[Thumbnail for QQ截图20110922094459.png]


** SCJP 5.0 84% **
** SCWCD 1.5 76% **
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Chrix Wu wrote:When Object B's caller() is invoked, is the new version of callee() going to be invoked too?


I'd suggest you try writing some Java code, compiling it, and running it. Then you will get your answer. Simple


SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2541
    
  10

Sean Keane wrote:
I'd suggest you try writing some Java code, compiling it, and running it. Then you will get your answer. Simple
That is an excellent advice.
The best way to understand what is happening, is to code an example and see what it does.

You could use a debugger and step through your code to follow the methods that are called.
There is no magic involved, and it is fun to learn how the mechanism works that way.


OCUP UML fundamental and ITIL foundation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: questions about method overriding
 
It's not a secret anymore!