| |
5. 22. 1. 继承 |
|
- You extend a class by creating a new class.
- The former and the latter will then have a parent-child relationship.
- The original class is the parent class or the base class or the superclass.
- The new class is called a child class or a subclass or a derived class of the parent.
- The process of extending a class in object-oriented programming is called inheritance.
- In a subclass you can add new methods and new fields as well as override existing methods in the parent class to change their behaviors.
- Inheritance gives you the opportunity to add some functionality that does not exist in the original class.
- Inheritance can also change the behaviors of the existing class to better suit your needs.
- The subclass and the superclass has an "is-a" relationship.
|
|