1.
Write a Java program to create a class called Animal with a method called
makeSound(). Create a subclass called Cat that overrides the makeSound() method to
bark.
2. 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".
3. Write a Java program to create a class called Shape with a method called
getArea(). Create a subclass called Rectangle that overrides the getArea() method
to calculate the area of a rectangle.
4. Write a Java program to create a class called Employee with methods called
work() and getSalary(). Create a subclass called HRManager that overrides the
work() method and adds a new method called addEmployee().
5. Write a Java program to create a class known as "BankAccount" with methods
called deposit() and withdraw(). Create a subclass called SavingsAccount that
overrides the withdraw() method to prevent withdrawals if the account balance falls
below one hundred.
6. Write a Java program to create a class called Animal with a method named move().
Create a subclass called Cheetah that overrides the move() method to run.
7. Write a Java program to create a class known as Person with methods called
getFirstName() and getLastName(). Create a subclass called Employee that adds a new
method named getEmployeeId() and overrides the getLastName() method to include the
employee's job title.
8. Write a Java program to create a class called Shape with methods called
getPerimeter() and getArea(). Create a subclass called Circle that overrides the
getPerimeter() and getArea() methods to calculate the area and perimeter of a
circle.
9. 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.
10. 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.
Multilevel Inheritance Problem
Create a class “Person” with fields “name” and “age” and a method “display()” that
prints the name and age of the person.
Create a subclass “Employee” that extends “Person” and adds a field “salary” and a
method “display()” that prints the name, age, and salary of the employee.
Create a subclass “Manager” that extends “Employee” and adds a field “department”
and a method “display()” that prints the name, age, salary, and department of the
manager.
Create an object of the “Person” class and call the “display()” method.
Create an object of the “Employee” class and call the “display()” method.
Create an object of the “Manager” class and call the “display()” method.