The polymorphism is the third basic feature of object-oriented programming after data abstraction and inheritance.
"Scalable" means that the program is "growth" not only in the initial development phase of the project, and it can also "growth" when needed to add new features. "Package" refers to the characteristics of data and the behavior, create A new data type. "Hidden Implementation" is set to Private, complete the separation of the interface and implementation.
Connecting the method of the method to the method itself is called "binding". When the binding occurs before the program is running (if any, if any
Or the connector is responsible for the pre-binding. Then the binding means to determine which method of the binding according to the object when the program is running, and the binding is also called dynamic binding
(Run-time binding) or running bindings in addition to static and final methods Java, it is bound. This is to say that you don't have to consider if you don't have to consider it.
After binding - it is automatic.
Only the private method can be overwritten because private hidden contains Final.
Abstract class provides public interfaces for all the classes they derive. When you want to control a group through a public interface
The abstraction method is an abstract method. The abstract method is a method that has not been completed. This method only has a declaration, there is no body. The class containing the abstract method is called "abstract class", if the class
Contains one or more abstract methods, then this class must be defined as Abstract. (Otherwise the compiler will report an error.) The compiler cannot securely create this new class object, you must inherit the abstract class, and create this Object, achieve all of the pumping defined by the base class
Like method. If you don't do this, the class inherited will become an abstract class, the compiler will force you to declare this class with the Abstract keyword.
The constructor is not a polymorphic (in fact, they are static methods, but they are not directly said when the declaration is declared).
In the process of creating a party, the constructor of the base class is always called first, (because it is known that the object is not created correctly, derived class
Only by accessing its own members, it can't see members of the base class. Only the constructor of the base class knows the members who correctly initialize its (because
It is very important to call all the "constructor" to call all the "constructor").
The call sequence of the constructor of complex objects is such: 1. Before performing other work, the memory assigned to this object will be initialized into two-way zero .2. Tuning the construction function of the base class first. Data. Data Members are initialized in order of their statements. 4. Call the body of the derived class constructor.
The premise of inheritance is that you can see the base class and access its public and protected members.
Inheritance and cleanup new categories have both synthesis and inheritance, most cases you don't have to worry about cleaning: Sub-objects can be handled by garbage collectors. Such as
If you want to write (such as Dispose ()), the first thing to remember is to call the Dispose () method of the base class.
A good constructor should use the least amount of work to set the status of the object, and avoid the calling method. The constructor is unique
The method of secure call is the foundation class final method (this is also suitable for the Private method, because it is automatically final), they will not be overwritten,
Therefore, there will be no such accident.
Inheritance and synthesis is best to consider synthesis, especially when you don't know which class is inherited. If you use inheritance, you may aggravate the burden of design.
The best way to study inheritance is to create a class in the way "pure inheritance". That is to say, derived classes only overwritten the base class or Interface
Method. You can imagine a Pure Substitution. You can use the object of the derived class to replace the base class object.
Downcast must use a parentheses as an ordinary type conversion. When running, the system will check these conversion, ensuring that it does
It is the type you want to convert. If not, you will get a ClassCastException. This type of runtime check is called "running
Type Identification (Run-Time Type Identification Abbreviation is RTTI).