java – Explain visually the difference between early and late method binding.

Question:

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:

Early binding is when the method to be called is known at compile time, such as calling a static method.

By the way, what you call late binding is rather 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.

Scroll to Top