Inheritance Hands-On Activities
Inheritance Hands-On Activities
Add a
new instance variable named "department" of type String and modify the constructor
to accept a new parameter for department. Implement a display() method in the
Manager class that calls the display() method in the parent class and also displays
the department of the manager.
2. Create a new child class named "Retiree" that extends the Person class. Add a
new instance variable named "pension" of type double and modify the constructor to
accept a new parameter for pension. Implement a display() method in the Retiree
class that calls the display() method in the parent class and also displays the
pension of the retiree.
3. Modify the Student class to include a new instance variable named "GPA" of type
double. Implement a display() method in the Student class that calls the display()
method in the parent class and also displays the GPA of the student.
4. Create a new parent class named "Human" that has instance variables for name and
age, and a display() method that displays the name and age of the human. Modify the
Person class to inherit from the Human class, and modify the Student and Employee
classes to inherit from the Person class.
5. Create a new child class named "PartTimeEmployee" that extends the Employee
class. Add a new instance variable named "hourlyRate" of type double and modify the
constructor to accept a new parameter for hourly rate. Implement a display() method
in the PartTimeEmployee class that calls the display() method in the parent class
and also displays the hourly rate of the part-time employee.