Encapsulation: Hides some information about a class inside a class, does not allow external programs to access directly, but instead uses the methods provided by the class to manipulate hidden information
1. Modify the visibility of the properties of the class and restrict it by private;
2. Perform the appropriate action on the property by the specified method
Inheritance: Inheritance in Java is a single inheritance, inheriting the properties and methods of the parent class (the base class), and can override the parent class method in the subclass (derived class);
Polymorphism: Inheritance is the basis for polymorphism
1. The object of the parent class can point to a reference to the parent class;
2. The object of the parent class can point to a reference to the subclass;
3. The object of the subclass cannot point to a reference to the parent class;
4. The polymorphism of the method is to invoke the method of the different subclasses to execute the corresponding class method, the method of the class is preferred to execute, in the case of the absence of this class in the parent class to find;
5. Subclasses can have different expressive forms, animals (dogs, cats, Fox);
Java encapsulation, inheritance, polymorphism