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 (VehicleLandVehicleCar), 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()
  • LandVehicle class (abstract, inherits Vehicle):
    • Implement getType() to return "Land"
    • move() remains unimplemented (stays abstract)
  • Car class (inherits LandVehicle):
    • Implement move() to output "Driving on road"
  • In Main class, create Car object and call getType() and move()

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