1. OOP spirit: package, polymorphism and inheritance
Class, used to create an object's template, which specifies the data inside the object, creates the characteristics of the object, and the object
Its own data runs. There can only be a class definition in the program, but there are multiple class instance objects. The instance object is created with New.
Method, the operation on the object can be performed, must belong to a certain class.
2. The extends keyword indicates that the left is the subclass of the right side.
3. Super Keywords are used to reference the parent (super) class variables or methods.
4. Operator InstanceOf Judging the type of variable.
5. Object Type Conversion To: Subcarrees Convert to Parental Class, Allow Implicit Switching down: Parental Class Convert to Subclasses, must force conversion, that is, the parent class object gives all methods and variables defined by subclasses
The forced type conversion did not change the original object, just generated a reference for the purpose of the original object. Original object
There is now.
6. Algorite collection (Different from polymorphism) Object collects various derivative elements, is a typical heterogeneous collection, that is, where you can use the parent class object.
You can use a subclass object, which is often used for parameter delivery.
7. Single inheritance A class has only one superclass or parent class, called single inheritance, making the code more secure. Subclasses inherit the formation letter in the parent class
All methods and variables outside. A class or sub-definition constructor or use the default constructor.
8. Polymorphism is a runtime issue, and the function overload is a compile time. The specific manifestation is: subclass of heavy writing
The variables of the class, the method of renovation of the parent class in the subclass, in the class (itself) or in the inheritance relationship (parent class and subclass) forms a function overload. When the sub-objects are assigned to the parent class, "the same name is different" and constitute a polymorphism. However, when using the member variable of the variable access object, only the types and parent classs of the type corresponding to the variable can be accessed. The part added in the subclass is hidden.
9. Package data hide usually refers to packaging. It distinguishes the external interface of the class with the implementation of the class and hides the implementation details. force
Use the household to use the external interface, even if the details change, you can also bear the functionality through the interface and retain it to ensure that the code calls it continues. Public: You can be accessed anywhere. Private: You can only access in the class. Protected: Access in subclass of different packages. Without modification, you can be accessed in all of the same packets, and you can access between members in the same class.