Challenge: Create an Abstract Class and Derive Classes from It

Create an abstract class, derive two classes from it, and then call the methods using objects of derived classes.

Create an abstract class called Vehicle that contains the methods speed(), maintenance(), and value(). Derive classes FourWheeler and TwoWheeler from the Vehicle class. Determine whether you are able to prevent the creation of objects of the Vehicle class. Call the methods using objects of other classes:

  • Input: We will not pass any input parameters.
  • Output: We will print the simple messages using the print statements inside the methods of derived classes.

Get hands-on with 1200+ tech skills courses.