File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Inheritance , dynamic binding? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inheritance , dynamic binding?" Watch "Inheritance , dynamic binding?" New topic
Author

Inheritance , dynamic binding?

Zeeman Chen
Greenhorn

Joined: Oct 30, 2003
Posts: 9
I cannot understand what's going on behind the code.
the result is
3
MOVE
if I hadn't written :
v =d; // upcasting , safe
runtime error since d= (Dog)v; downcasting unsafe.

who can tell me what happend in memory after the following two
lines?
thanks in advance!
v= d;
d = (Dog)v;




If a man take no thought at what is distant, he will find sorrow near at hand. ~ Confucius
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
One way to see for yourself how things work here is to rename move1(), move2(), and move3() all to move(). Then add some calls to move() from main() like this:


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inheritance , dynamic binding?