Inheritance is to create a new class based on a certain class ** class New class name (original class name): You can define a new class by inheriting another class by writing **. The original class at this time is called the ** parent class **, and the new class is called the ** child class **. When inherited, the child class inherits the instance method of the parent class The child class can use both "methods defined in the parent class" and "methods defined independently". You can override the method by defining a method with the same name as the parent class in the child class. This is called the method ** override ** When overridden, the method defined in the child class takes precedence You can call the parent class by using ** super () ** in the overridden method. By using ** super (). method name () **, the instance method defined in the parent class can be used as it is.
Recommended Posts