Java looks in the declared (apparent) type of an object to see what methods are available to that object (it doesn’t matter how the object is instantiated).
Java只会看apparent type, 去寻找里面的有效的methods而不是在actual type里面寻找。
Example:
public class Plane() {
void takeOff();
void fly();
}
public class PrivatePlane() extends Plane {
void bringWarmTools();
}
PrivatePlane pp
= new PrivatePlane();
pp
.bringWarmTools();
Plane plane
= new Plane();
plane
.bringWarmTools();