Late binding of methods is when there is a reference variable, and depending on which instance of which class will be created, the corresponding method will be called. What about early binding, what’s the difference?
Answer 1, authority 100%
Early binding is when the method to be called is known at compile time, such as a call to a static method.
By the way, what you call late binding is more of a dynamic dispatch.
Late binding is when a method call can only be made at runtime, and the compiler has no information to verify the correctness of such a call. In java, this can be done using reflection.
Answer 2, authority 90%
Early binding, as noted above, occurs at compile time. It is used when calling normal methods (not virtual).
Late binding, on the other hand, occurs at runtime. It is performed when the virtual functions of the descendant class are called to determine which method should be called.
Based on the fact that early binding is done at compile time and later at runtime, the first option has better performance, but the second is necessary to implement polymorphism.
As for Java, I can say that there, if I’m not mistaken, all methods are defaulted to late binding (unless they are marked with the final modifier), unlike, say, C++, where early binding is applied by default.
For more understanding of the issue, read about virtual method table
Z.Y. I’m not familiar with Java, so I can’t say for sure how the term “function” is applicable there