Ask Question

Vehicle aVehicle = new Auto (); aVehicle. moveForward (200); Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type. What determines which class's moveForward method is to be executed? A. the actual object type. B. the variable's type. C. the hierarchy of the classes. D. it is not possible to determine which method is executed.

+5
Answers (1)
  1. 4 April, 06:20
    0
    Hi!

    The correct answer is A) the actual object type.

    Explanation:

    The Auto class inherits from Vehicle class. This means that Auto inherit attributes and methods from Vehicle, but moveForward method has an implementation in Auto class with the same set of parameters and same return type (or sub-type) as a method in Vehicle, then the method in the Auto is said to override the method in the Vehicle. So, the actual object type will be executed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Vehicle aVehicle = new Auto (); aVehicle. moveForward (200); Assume that the Auto class inherits from the Vehicle class, and both classes ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers