Mind map
Inheritance
Map content
Inheritance
Defined as a relationship between objects that share characteristics
- I.e. -- a new class, aka subclass, is created from an existing class (superclass) by absorbing its state and behavior.
- The subclass INHERITS characteristics of its superclass.
- In code, the relationship is specified in the declaration of the subclass, using the keyword "extends".
- I.e. -- a new class, aka subclass, is created from an existing class (superclass) by absorbing its state and behavior.
Works by hierarchy
- See the following chart:
- Person
- Student
- GradStudent
- UnderGrad
- Employee
- Student
- The relationship between classes is called an "is-a" relationship.
- Person
- Subclasses can only inherit from a superclass. Subclass cannot inherit from another subclass, and a superclass cannot inherit from a subclass.
- A subclass may inherit the public/protected variables and methods of its superclass, as well as have additional methods and instance variables not in the superclass as well.
- Subclasses can redefine the method it inherits as well.
- I.E. Gradstudent and undergrad may use different algorithms for computing the course grade by changing the computeGrade method inherited from Student.
- Subclasses can redefine the method it inherits as well.
- A subclass may inherit the public/protected variables and methods of its superclass, as well as have additional methods and instance variables not in the superclass as well.
- See the following chart:
Information
- Description
- A small mindmap on inheritance.
- Created by
- Nik Nguyen · Apr 2016
- Updated
- Jul 28, 2016
- Views
- 129
- Tags
- Rating