Helicopter h = (Helicopter) new Rotorcraft();
)以及
throws
Runtime exception
类型
ClassCastException
.
基类:
public class Rotorcraft {
protected final int height = 5;
protected int fly(){
return height;
}
}
public class Helicopter extends Rotorcraft {
private int height = 10;
public int fly() {
return super.height;
}
public static final void main(String[] a){
Helicopter h = (Helicopter) new Rotorcraft();
}
}