Late binding:

The concept of binding the function body to the function definition during runtime is known as late binding. Weimplement late binding through interfaces in java.

Early binding:
If the function body is binded with the function definition at the compilation time, then it is known as early binding.



We cannot define a function in a class without body. It should have at least zero body.


Difference between late binding and dynamic polymorphism:

  • In dynamic polymorphism the function to be executed is decided at runtime but note that by the time of compilation the function has a body.
  • But, in the late binding, the body of the function itself is going to get associated with the function definition during the runtime.
  • Late binding is highly dynamic than anything else in java.


Consider the following scenario:

Assume that same person Mr. X has created a class with some statements which is responsible for the creation of a GUI

Class MY Button


My Button ()


-------                            \\ statement responsible for creation of the GUI.




Let us assume that we are using this MY Button class object in our program

Class Test


Void fun1 ()


Public static void main (string args [ ])


Test t1 = new test ();

My Button b1 = new MY button ();

B1 .find click ();



Contents of function 1() should be executed only when the button is clicked. so for this , we should have another function in my button class which recognizes the click of the button. Let that function as follows

Void find click ()


Wait for the button to be clicked

If (button is clicked)

Execute statement of function1 ();


Now, if we analyze the entire scenario, it is as follows.

Mr. X has created a class MY Button and in that he has a function function1 () changes according to the need of the users who use his class in their programs. It is something like, calling a function whose functionality is not known during compilation time. Now when the button is clicked, b1 .find click () is called and from that function.


Late binding and Early binding Homework Help