Car extends Vehicle
&
Car implements LandMover
Vehicle vec = (Vehicle)lmv;
( ), lmv
, LandMover
, , CAN be Car
( Car implements LandMover
). Car extends Vehicle
.
to confirm , try commenting out the code as follows
LandMover lmv;
Vehicle vec = (Vehicle)lmv;
Here the compiler is sure that it lmv
CANNOT be Vehicle
, and therefore a flag error.
source
share