1. Polymorphism (polymorphism):
Polymorphism refers to the specific type of reference variable defined in the program and the method call emitted by the reference variable is not determined during programming, but is determined during the program's run, that is, a reference to which the variable is inverted to the instance object of the class that the reference variable emits, and the method called by which class is implemented. Must be determined by the time the program is running. This is polymorphism. Polymorphism enhances the flexibility and extensibility of the software.
To put it simply: send a message to an object and let the object decide for itself what behavior to respond to. A dynamic method call is implemented by assigning a subclass object reference to a superclass object reference variable.
Polymorphism must have:
A. Base classes and individual subclasses
B. A base class reference that points to the instantiated subclass object.
"Computer Graphics" in the plotting logic is polymorphic, the realization of the point line element management, call the parent class draw method, the last point of the line surface of the child elements to draw.
2. Overwrite (override)
A, the mark of the method of coverage must match with the mark of the method that is covered, can reach the effect of coverage;
b, the return value of the overridden method must be consistent with the return of the overridden method;
C, the overridden method throws an exception that must be the same as the exception that is thrown by the overridden method, or its subclass;
D, the overridden method cannot be private, otherwise only a new method is defined in its subclass and is not overwritten
3. Overloading (overload)
A, you can only pass different parameter styles when using overloads. For example, different parameter types, different number of parameters, different parameter order (of course, several parameter types within the same method must differ, such as can be fun (int, float), but not fun (int, int));
B, cannot be overloaded by Access permission, return type, exception thrown;
C, the exception type and number of methods will not affect the overload;
D, for inheritance, if a method is priavte in the parent class, then it cannot be overloaded in subclasses, and if defined, it simply defines a new method without overloading the effect.
Java polymorphism, overloading, overriding