What Is Dynamic Binding in Java?

Dynamic binding is the process of connecting a function (procedure call) to a specific method (sequence of code) at run time. This means that function to be executed by a method remains unknown until run-time. Dynamic binding is also referred to as run-time binding or late binding.

The concept of binding is closely related to other object-oriented programming concepts such as inheritance and polymorphism. Binding simply refers to link between method definition and method call. Actual objects are used during run time for binding. Dynamic binding enables developers to interface new code sequences and objects with a system without altering the existing code thus eliminating switch statements. Method overriding is a good example of dynamic binding.

The opposite of dynamic binding is static binding. Unlike dynamic binding, static binding occurs during compilation. It is sometimes referred to as early binding because the binding occurs before the application runs. A good example of static binding is method overloading. Another key difference between the two binding types is that static binding utilizes class information for binding while dynamic binding utilizes objects to resolve binding. The time at which binding occurs affects the overall performance of the program. If the binding occurs earlier, safety and efficiency increases while flexibility decreases.