0% found this document useful (0 votes)
8 views1 page

Inheritance

Uploaded by

20234203064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Inheritance

Uploaded by

20234203064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Inheritance

1. Write a Java program to create a class called Shape with a method called
Area(). Create a subclass called Rectangle that overrides the Area()
method to calculate the area of a rectangle.
2. Write a Java program to create a vehicle class hierarchy. The base class
should be Vehicle, with subclasses Truck, Car and Motorcycle. Each
subclass should have properties such as make, model, year, and fuel type.
Implement methods for calculating fuel efficiency, distance traveled, and
maximum speed.
3. Write a Java program that creates a class hierarchy for employees of a
company. The base class should be Employee, with subclasses Manager,
Developer, and Programmer. Each subclass should have properties such
as name, address, salary, and job title. Implement methods for calculating
bonuses, generating performance reports, and managing projects.

You might also like