G.1 Introduction to Inheritance
The first part of this appendix continues our discussion of object-oriented programming (OOP) by introducing one of its primary capabilities—inheritance
, which is a form of software reuse in which a new class is created by absorbing an existing class’s members and embellishing them with new or modified capabilities. With inheritance, you can save time during program development by basing new classes on existing proven and debugged high-quality software. The existing class is called the superclass
, and the new class is the subclass.
Each subclass can become a superclass for future subclasses.
A subclass can add its own fields and methods. Therefore, a subclass is more specific than its superclass and represents ...
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.