Professional Documents
Culture Documents
Lab Plan 4
Lab Plan 4
This lab plan is intended to be completed individually, so it is important to exercise caution and refrain
from plagiarizing the work of others. If any instances of copying are identified, both parties involved
will receive a score of zero. Additionally, it is advisable to take measures to safeguard your assignment
from unauthorized access by others. There will be no exceptions or excuses accepted for cases of
plagiarism or facilitating plagiarism.
Question #01:
Write a Java program to create a class called Vehicle with a method called drive(). Create a
subclass called Car that overrides the drive() method to print "Repairing a car".
Question#02:
Design a class hierarchy to model different types of vehicles. Start with a base class Vehicle and
create child classes Car and Motorcycle inheriting from it. Further, create child classes
ElectricCar and GasolineCar inheriting from Car, and SportsBike and TouringBike inheriting
from Motorcycle. Implement methods specific to each class, such as start_engine() for cars and
start_engine() for motorcycles. Ensure that common functionality is appropriately inherited
across the hierarchy.