Consider a class hierarchy that includes a class called Vehicle, with subclasses called Car and Airplane. The Vehicle class has a method called getMaxSpeed, which is overridden in the Car class. The getMaxSpeed of the Vehicle class returns 760 mph, while the getMaxSpeed method of the Car class is overridden to return 150 mph. What is the output of the following snippet of code? Explain your answer.
Vehicle v = new Car();
System.out.println(v.getMaxSpeed() + " mph");
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q23: Consider the following inheritance hierarchy that is
Q24: A single class may implement multiple interfaces.
Q25: Describe the compareTo method the circumstances under
Q26: Are there any differences between extending a
Q29: What is an interface?
Q30: Write an interface for a CD player.
Q31: An interface name may be used as
Q32: How does inheritance relate to polymorphism in
Q33: Can references to interface types be polymorphic?
Q102: What is polymorphism?
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents