Exercises (Sections G.1G.5)

  1. G.5 Discuss the ways in which inheritance promotes software reuse, saves time during program development and helps prevent errors.

  2. 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 extend Student with classes Under-graduateStudent and GraduateStudent. Continue to extend the hierarchy as deep (i.e., as many levels) as possible. For example, Freshman, Sophomore, Junior and Senior might extend UndergraduateStudent, and DoctoralStudent and MastersStudent might be subclasses of GraduateStudent. 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.