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

Java Problems

The document outlines various Java inheritance problems, including creating class hierarchies for shapes, employees, vehicles, bank accounts, schools, animals, and media types. Each problem emphasizes the implementation of base and subclass relationships, with specific methods for calculating properties or handling unique functionalities. Additionally, it includes tasks related to sorting shapes and managing payroll systems using polymorphism and inheritance.

Uploaded by

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

Java Problems

The document outlines various Java inheritance problems, including creating class hierarchies for shapes, employees, vehicles, bank accounts, schools, animals, and media types. Each problem emphasizes the implementation of base and subclass relationships, with specific methods for calculating properties or handling unique functionalities. Additionally, it includes tasks related to sorting shapes and managing payroll systems using polymorphism and inheritance.

Uploaded by

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

JAVA INHERITANCE PROBLEMS

1. Shape Hierarchy: Create a hierarchy of shapes (e.g., Circle, Rectangle, Triangle) where
each shape has common properties (e.g., area, perimeter). Implement methods to
calculate area and perimeter for each shape.

2. Employee Inheritance: Create a class hierarchy for employees. There should be a base
class Employee, and subclasses Manager and Clerk. Each subclass should have its own
method for calculating salary based on its specific criteria.

3. Vehicle Inheritance: Design a class hierarchy for vehicles. Create a base class Vehicle,
and subclasses Car, Truck, and Motorcycle. Each subclass should have its own unique
properties and methods, along with inheriting common properties from the Vehicle class.

4. Bank Account Inheritance: Create a hierarchy of bank accounts. Implement a base


class Account with subclasses SavingsAccount and CurrentAccount. Include methods to
deposit, withdraw, and calculate interest (for SavingsAccount).

5. School Hierarchy: Design a class hierarchy for a school system. Create a base class
Person with subclasses Student and Teacher. Each subclass should have its own unique
properties and methods.

6. Animal Inheritance: Create a class hierarchy for animals. Design a base class Animal
with subclasses Mammal, Bird, and Fish. Implement methods to display information
specific to each subclass.

7. Shape Sorting: Implement a program that creates an array of various shapes (e.g.,
Circle, Rectangle, Triangle) and sorts them based on their area.

8. Polymorphism with Shapes: Create a program where you have an array of different
shapes. Implement a method that calculates the total area of all shapes in the array,
utilizing polymorphism.

9. Employee Payroll System: Develop a program to manage the payroll system of a


company. Use inheritance to create classes such as Employee, HourlyEmployee, and
SalariedEmployee. Calculate the total payroll of the company.

10. Media Hierarchy: Design a class hierarchy for media types. Create a base class
MediaItem with subclasses Book, Movie, and MusicAlbum. Each subclass should have
its own unique properties and methods.

You might also like