Summary of the contents of teaching materials sub-category and inheritance
Subclass and Parent class
The standard format defined is
class 子类名 extends 父类名 {...}
If a keyword is not used in the declaration of a class, the extends
default is the object class.
- Inheritance of subclasses
The criterion for judging whether or not to inherit is to see if the subclass can manipulate the member variable of the parent class , and if the child class is in the same package as the parent class , the inheritance is not private , not in the same package, and the subclass inherits only the protected and public classes.
- Subclasses and objects
About the instanceof operator there should be an operand to the left, the action element on the right is the class
Hide and method overrides for member variables
When you write a subclass, the name of the member variable that is generated is the same as the inherited name, and the subclass hides the inherited member variable.
Test the wrong question in the third week
20165221 Java Fourth Week learning experience