Lab 6

(week of Mar 2--6)


The purpose of this lab is to practice programming inheritance.

There is only one part in Lab 6.  No debug questions in Lab 6.


Question 1:

Implement a superclass "Person". Make two classes, "Student" and "Instructor", that inherit from "Person". A person has a name and a year of birth. A student has a major, and an instructor has a salary. Write the class definitions, the constructors, and the methods "toString" for all classes. Supply a test program that tests these classes and methods.


Question 2:

Make a class "Employee" with a name and salary. Make a class "Manger" inherit from "Employee". Add an instance field, named "department", of type String. Supply a method "toString" that prints the manger's name, department, and salary. Make a class "Executive" inherit from "Manager". Supply appropriate "toString" methods for all classes. Supply a test program that tests these classes and methods.