1. Face-to-face objects are divided into face-to-face objects (leader's thought) and face-to-face process (executor's thought);
Second, face to face the three major characteristics of the object: encapsulation inheritance polymorphism;
Three, create object format: class name object name = new class name ();
Fourth, the benefits of encapsulation: improve the reusability of the code, ② hide the implementation details, provide public access to the external; keyword private
Fifth, this mainly distinguishes member variables and local variables with the same name variable
6. Inheritance keyword extends keyword Function: Improve code reuse ② The relationship between classes
Subclass access to parent class member variable format Use super. Member variable in parent class
The subclass method overrides the parent class method, you must ensure that the permissions are greater than or equal to the parent class permissions (now commonly used equal to the parent class permissions common permission name public)
Seven, abstract class: abstract method definition format
public abstract return value type method name (parameter);
Eight, the interface: the keyword interface class implements the interface using the keyword implements
Features of the members in the interface:
① There must be fixed modifiers such as: public static final
②The interface can define methods and methods have fixed modifiers, public abstract
③ The interface cannot create objects
④Subclasses must override all abstract methods in the interface before they can be instantiated. Otherwise the subclass is an abstract class
⑤ The interface can inherit more:
⑥The interface can be realized more:
Nine, polymorphism: the parent class points to the child class
The prerequisite for polymorphism is that there must be a child-parent relationship or class implementation interface relationship, otherwise polymorphism cannot be completed .
When calling a method using a polymorphic parent class reference variable, the subclassed method will be called.
Format: ordinary class: parent class variable name = new subclass ();
Abstract class: abstract class variable name = new abstract class subclass ();
Interface: interface variable name = new interface class implementation ();
Ten, determine whether an object belongs to a certain data type (simple understanding is to determine whether it is a subclass ); use the keyword instanceof
11. Polymorphic (usually downward transformation) format: subclass type variable name = (subclass type) parent type variable;
Such as : Student stu = (Student) p; // The variable p actually points to the Student object
12. Construction method:
Modifier construction method name ( parameter list) {
} No return value type does not need to write the return value, usually used together with the above four, five;
13. The final keyword final modification class cannot be inherited, but can inherit other classes. Cannot be overridden by subclasses
l Final modified variables are called constants. These variables can only be assigned once and will remain unchanged for life.
class Yy {}
final class Fu extends Yy {} // Can inherit Yy class
class Zi extends Fu {} // Cannot inherit Fu class
Fourteen, statically modified static class name can not be used directly call this \ super
15. Anonymous object: new object ();