Solution to Draw an inheritance hierarchy for students at a university. Use Student as the base class … - Sikademy

Nov. 27, 2020

Archangel Macsika Sikademy Image

Archangel Macsika

Draw an inheritance hierarchy for students at a university. Use Student as the base class of the hierarchy, then include classes UndergraduateStudent and GraduateStudent that derive from Student. Continue to extend the hierarchy as deep (i.e., as many levels) as possible. For example, Freshman, Sophomore, Junior and Senior might derive from UndergraduateStudent, and DoctoralStudent and MastersStudent might derive from Graduate- Student. After drawing the hierarchy, discuss the relationships that exist between the classes. [Note: You do not need to write any code for this exercise.]

Solution

This hierarchy contains many “is-a” (inheritance) relationships. An UndergraduateStudent is a Student.

A GraduateStudent is a Student too. Each of the classes Freshman, Sophomore, Junior and Senior is an UndergraduateStudent and is a Student. Each of the classes DoctoralStudent and MastersStudent is a GraduateStudent and is a Student.

Each of the classes DoctoralStudent and MastersStudent is a GraduateStudent and is a Student.