I have a Vehicle class. From the car I am expanding the Car class (and some others, such as Bus, Bike ..). Now in my application I do not know which car the user will work with. Therefore, I create a Vehicle object, and then assign it the corresponding object (Car, Bus, ...). After that, I want to name the Car function, but I cannot achieve it. Why?
Vehicle vehicle=null; . . . vehicle=new Car(); vehicle.someMethodFromCar();
source share