Exercises (Sections G.1G.5)
-
G.5 Discuss the ways in which inheritance promotes software reuse, saves time during program development and helps prevent errors.
-
G.6 Draw an inheritance hierarchy for students at a university similar to the hierarchy shown in Fig. G.2. Use
Student
as the superclass of the hierarchy, then extendStudent
with classesUnder-graduateStudent
andGraduateStudent
. Continue to extend the hierarchy as deep (i.e., as many levels) as possible. For example,Freshman
,Sophomore, Junior
andSenior
might extendUndergraduateStudent
, andDoctoralStudent
andMastersStudent
might be subclasses ofGraduateStudent
. After drawing the hierarchy, discuss the relationships that exist between the classes. [Note: You do not need to ...
Get Android How to Program, 3/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.