Inheritance Example

Write a Student class and a Teacher class that extend the Person class.

public class Person
{ private String name;
private int age;
private String gender; // M or F
_______________;
_______________;

}

1. Write the constructor, the toString (returns name, age and gender),accessors and modifiers for the above class.



2. Write a Student class that extends the Person class. The Student class will have an id number (String) and a GPA (double). Write the constructor and appropriate accessors and modifiers for the class. Overwrite the toString class to return the GPA in addition to the other info.


3. Write a Teacher class that extends the Person class. The Teacher class will have a subjectTaught field. Write constructor and appropriate accessors and modifiers. Overwrite the toString class to return subject in addition to the other information.


4. Write another class that will add 3 teachers, 3 students and 3 persons to an ArrayList of Persons. Then use a for loop to print out the information about each of the Persons in your ArrayList.