016-003-006
Abstract Class: Inheritance Hierarchy
Hard
Problem Description
abstract class: inheritance Hierarchy
In this problem, you will create a program that implements a multi-level abstract class hierarchy (Vehicle → LandVehicle → Car), progressively implementing abstract methods at each level, and displays the result to standard output.
Learning Objective: Understand multi-level inheritance hierarchy using abstract classes
Overview
Inherit a LandVehicle abstract class from a Vehicle abstract class, then implement a concrete Car class. Implement multiple abstract methods progressively.
Specifications
- Vehicle class (abstract):
- Define abstract method
move() - Define abstract method
getType()
- Define abstract method
- LandVehicle class (abstract, inherits Vehicle):
- Implement
getType()to return "Land" move()remains unimplemented (stays abstract)
- Implement
- Car class (inherits LandVehicle):
- Implement
move()to output "Driving on road"
- Implement
- In Main class, create Car object and call
getType()andmove()
Output Format
Land
Driving on road
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up