Definition of inheritance The so-called class inheritance means that the subclass inherits the member variables and methods of the parent class as its own member variables and methods, as if they were declared directly in the subclass. Of course, there are some restrictions on whether the subclass can inherit the variables and methods of the parent class. It is described in detail below.
Inheritance of children and parents in the same package If the subclass and the parent are in the same package, the subclass naturally inherits the member variable that is not private in its parent class as its own member variable, and also naturally inherits the method that is not private in its parent class as its own method. Inherited member variables and method access remain unchanged.