previous | next |
class Animal { void move(Animal x ) { . . . } } |
class Bird extends Animal {
Animal ted ;}. . .void fly( ){ted = new Animal( );} |
class Animal {
void move(Animal x){ code 1 } } |
class Bird extends Animal {
Animal ted; // static type ??}. . .void move(Animal x ) { code 2 } |
Different code is executed! The determination of which code is used is made at run-time depending on the dynamic type of the OBJECT.
class Animal { ... void move(Animal x ) { CODE 1 } ... } |
class Mammal extends Animal {
Animal ted;} |