Draw an inheritance hierarchy for students at a university. Use Student as the b
ID: 653381 • Letter: D
Question
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 GraduateStudent. After drawing the hierarchy, discuss the relationships
that exist between the classes. [Note: You do not need to write any code for this exercise.]
Explanation / Answer
class Student
{
StudentID
Name
DOB
Student(studid,nm,bdate) {}
// accessor methods
}
// class UndergraduateStudent and GraduateStudent inherits Student
class UndergraduateStudent extends Student
{
}
class GraduateStudent extends Student
{
}
// classes that inherits UndergraduateStudent class
class Freshman extends UndergraduateStudent
{
YearofPassing
Grade
Institution
// getter and setter methods
}
class Sophomore extends UndergraduateStudent
{
}
class Junior extends UndergraduateStudent
{
YearofPassing
Grade
Institution
Subjectstaken
// getter and setter methods
}
class Senior extends UndergraduateStudent
{
YearofPassing
Grade
Institution
Subjectstaken
// getter and setter methods
}
// classes that inherits GraduateStudent
class MastersStudent extends GraduateStudent
{
YearofPassing
Grade
Institution
SubjectofSpecialization
// getter and setter methods
}
class DoctoralStudent extends GraduateStudent
{
SubjectofSpecialization
GuidingProfessor
// getter and setter methods
}
The class Student will have some basic member variables and methods. The member variables may include details like StudentID, Name etc which will private variables. The methods may include constructor with parameters like ID and name and the accessor methods which will have public access mode.
The inheriting classes like UndergraduateStudent and GraduateStudent may have further details. The inheriting classes of these classes UndergraduateStudent and GraduateStudent like FreshMan.Sophomore,Masters etc will have details like YearofPassing, Grade, Istitutiion etc. The main link between all the classes and its parent classes will be the StudentID.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.