0
21kviews
What Is Binding?Explain Static And Dynamic Binding.
1 Answer
3
1.9kviews

Binding refers to the link that is created between method call and method definition. It lets the system know which code should be executed in what manner. If any method call does not have a method definition, it results in the system showing an error. Static and dynamic binding determines when the code is actually executed.

enter image description here

While most references are resolved during compile time, there are some references that require an actual object and are resolved at run time. This is major difference between static and dynamic. Static binding happens when the code is compiled, while dynamic bind happens when the code is executed at run time.

Static Binding When compiler acknowledges all the information required to call a function or all the values of the variables during compile time, it is called “static binding”. As all the required information are known before runtime, it increases the program efficiency and it also enhances the speed of execution of a program. Static Binding makes a program very efficient, but it declines the program flexibility, as ‘values of variable’ and ‘function calling’ are predefined in the program. Static binding is implemented in a program at the time of coding. Overloading a function or an operator are the example of compile time polymorphism i.e. static binding.

Dynamic Binding Calling a function or assigning a value to a variable, at run-time is called “Dynamic Binding”. Dynamic binding can be associated with run time ‘polymorphism’ and ‘inheritance’ in OOP. Dynamic binding makes the execution of program flexible as it can be decided, what value should be assigned to the variable and which function should be called, at the time of program execution. But as this information is provided at run time it makes the execution slower as compared to static binding.

Please log in to add an answer.