| 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?
|
| Filename |
QQ截图20110922094459.png |
Download
|
| Description |
|
| Filesize |
3 Kbytes
|
| Downloaded: |
5 time(s) |
|
** 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: 2207
|
|
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.
|
 |
 |
|
|
subject: questions about method overriding
|
|
|