Why protected method is not accessible from subclass?
问题 Consider the following code snippets: package vehicle; public abstract class AbstractVehicle { protected int speedFactor() { return 5; } } package car; import vehicle.AbstractVehicle; public class SedanCar extends AbstractVehicle { public static void main(String[] args) { SedanCar sedan = new SedanCar(); sedan .speedFactor(); AbstractVehicle vehicle = new SedanCar(); // vehicle //WON'T compile // .speedFactor(); } } SedanCar is a subclass of AbstractVehicle which contains a protected method