1. Program bindings:
Binding refers to the invocation of a method associated with the class (method body) in which the method resides. For Java, bindings are divided into static and dynamic bindings, or pre-and late-binding.
2. Static bindings (pre-bind/compile-time bindings):
The method is already bound before the program executes, and is implemented by the compiler or other linker. For example: C.
For Java simple can be understood as the program compile time of the binding; In particular, the Java method is only final,static,private and the constructor method is pre-binding
3. Dynamic binding (late binding/Runtime binding):
Binds at run time based on the type of the specific object. If a language implements late binding, it must also provide mechanisms to determine the type of the object during run time and invoke the appropriate method, respectively. That is, the compiler still does not know the type of the object at this point, but the method invocation mechanism can investigate itself and find the correct method body. Different languages have a difference in how late binding is implemented. But at least we can think of it: they all have special types of information in the object.
The process of dynamic binding:
-The virtual machine extracts the actual type of object from the method table;
-Virtual machine search method signature;
-Call method.
4. Summary:
In Java, almost all methods are late-bound, and the dynamic binding method is either a subclass or a base class at run time. But there are also special, for the static method and the final method because cannot be inherited, so at compile time can determine their values, they belong to the early bound. Specifically, the method and member variables of the private declaration cannot be inherited by the quilt class, and all private methods are implicitly specified as final (we can also know that the method is declared as one of the final types to prevent the method from being overwritten. The second is to effectively close the dynamic bindings in Java. Late binding in Java is implemented with the JVM, and we don't have to explicitly declare it, and C + +, which must explicitly declare a method with late binding.
The upward transformation or polymorphism in Java is achieved through dynamic binding, so the dynamic binding is understood, and the upward transformation and polymorphism are done.
As we've already said, for the methods in Java, except for the Final,static,private and constructor methods, all the other methods are dynamically bound. The typical dynamic binding occurs under the transformation declaration of the parent class and subclass: Parent p = new Children ();
Method Bindings for Java