138k views
4 votes
Consider a class hierarchy that includes a class called Vehicles, with subclasses called and Airplane. The Vehicle class has a method called overridden in the class. The getMaxSpeed of the Vehicle class returns the method Car class I overridden to return 150 mph. What is the output of the following snippet of code?

User Or Gal
by
7.6k points

1 Answer

3 votes

Answer:

The code is not shared, but let me explain how it works. I believe there is also a class called Car.

Step-by-step explanation:

If the object is created using Car class - Vehicle ob = Car(); the result will be the return value of getMaxSpeed in Car class.

If the object is created using Airplane class - Vehicle ob = Airplane(); the result will be the return value of getMaxSpeed in Airplane class.

User Jonathan Molina
by
8.0k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.