answersLogoWhite

0


Best Answer

Static binding is where the linker copies the referenced module into the executable image of the program at compilation/link time. The referenced module becomes a part of the executable image. Dynamic binding is where the linker copies only a stub code for the referenced module into the executable image. That stub code loads the referenced module into memory at load/run time. Advantage of static is simplicity. The executable is stand-alone. Disadvantage is the executable image is larger, and if the referenced module changes, then each executable that uses it must be relinked. Another disadvantage is that if you have more than one executable using the module at the same time, you must have multiple copies of it in memory. Advantage of dynamic is reduced size of the executable image and that changing the referenced module does not require relink of the executable. Another advantage is that most operating systems can share the referenced module, meaning that only one copy of the referenced module need exist in all of memory for any number of references to that module, such as from multiple instances of the executable. Disadvantage of dynamic is that the executable is dependent on the shared library at run time. Another disadvantage is that, since the module is shared, it must be reentrant and thread safe, and this is not always done correctly.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Dynamic Binding or Late Binding

Dynamic Binding refers to the case where compiler is not able to resolve the call and the binding is done at runtime only. Let's try to understand this. Suppose we have a class named 'SuperClass' and another class named 'SubClass' extends it. Now a 'SuperClass' reference can be assigned to an object of the type 'SubClass' as well. If we have a method (say 'someMethod()') in the 'SuperClass' which we override in the 'SubClass' then a call of that method on a 'SuperClass' reference can only be resolved at runtime as the compiler can't be sure of what type of object this reference would be pointing to at runtime.

Static Binding or Early Binding

If the compiler can resolve the binding at the compile time only then such a binding is called Static Binding or Early Binding. All the instance method calls are always resolved at runtime, but all the static method calls are resolved at compile time itself and hence we have static binding for static method calls. Because static methods are class methods and hence they can be accessed using the class name itself (in fact they are encourgaed to be used using their corresponding class names only and not by using the object references) and therefore access to them is required to be resolved during compile time only using the compile time type information. That's the reason why static methods can not actually be overriden.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

The answer relates to how C++ (and C#) decides which particular function is being referred when a call is made.

Static (or early) binding is considered the traditional method because it most closely resembles the behavior of C and other older programming languages. This is most often seen in cases of function overloading: when one function name can be differentiated based on its parameters and/or return types. In a static bind, the decision is made at compile time. Based on the parameters passed and return expected, the compiler decides on a match for the call and sets the call to the appropriate version of the overloaded function. If a match cannot be made, the compiler returns an error indicating that no such overload exists (given enough verbosity, the compiler will usually attempt to describe the specific form of the function it was attempting to match).

Dynamic (or late or run-time) binding, as the name implies, only occurs while the program is executing. It is considered a key aspect of object-oriented languages because it contributes to polymorphism. True OO languages onlyallow for dynamic binding; C++ and C# allow for both. In C++ and C#, a dynamic bind usually occurs with virtual functions: member functions belonging to a base class that can be redefined in a derived class.

Here is the reason for the distinction. When class definitions are compiled, part of the process involves the assignment of addresses to member functions. An overridden member function of a derived class will have a different address than the same member belonging to the base class. If a pointer is declared belonging to the base class, but the pointer is then initialized (with the new keyword) as an instance of the derived class, then it becomes necessary to reset the member function's address, at run-time, to point to that of the derived class instead. The virtual keyword clues the compiler to this need by setting up the necessary mechanisms to allow for the reset to take place at run-time; otherwise, it will default to pointing to the member of the base class. In C#, the additional override keyword is used to specifically point to a derived function overriding the base function.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

When the method call is resolved at compile time, it is called as static binding,

when the method call is resolved at run time then it is called as dynamic binding.

In method overriding, the overridden method call is resolved using dynamic method dispatch(i.e it is resolved at run time).

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Dynamic binding is implemented in java using dynamic method dispatch.

Dynamic method dispatch means the method of the class will be called whose object is created.For example:

class Animal

{

pulic void eat()

{

}

}

class Cat extends Animal

{

pulic void eat()

{

}

}

public class A()

{

public static void main(String ar[])

{

Animal a = new Cat();

a.eat();

}

}

Since in the above example object of the child class is created,so eat() of child class is invoked.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Static binding applies to basically all c function calls.

Dynamic binding applies to calls to function pointers.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

static binding done at compile time where as dynamic binding done at run time. Dynamic binding is also called as Dyanamic method dispatcher.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between static binding and run time binding?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is Difference between dynamic polymorphism and static polymorphism with example?

Static polymorphism is used the concept of early binding or we can say compile time binding where as dynamic polymorphism used the concept of late binding or run time binding.


Static vs dynamic binding in c plus plus?

Static binding occurs at compile time. Dynamic binding occurs at runtime.


Is late binding and dynamic binding related to polymorphism?

Late binding and dynamic binding are related to runtime polymorphism. By contrast, compile time polymorphism is known as static binding. Template functions and classes are examples of static binding because the exact type can be determined at compile time.


What are the difference between static and dynamic hashing in DBMS?

Search operation in static hashing is time consuming, but in dynamic hashing it is not.


What is the general difference between a static IP and a dynamic IP?

The general difference between a static IP and dynamic IP is that a static IP is reserved and does not change. A dynamic IP on the other hand changes each time one logs on.


What is the difference in time between the differential and static pens of the barton meter chat?

15 minutes


Difference between static and dynamic ip address?

static stays the same, dynamic changes when you power on power off and after a certain amount of time.


What is the difference between Late binding and early binding?

Early binding. The type of the instance is determined in the compile time. It follows that the static (declared) type of the pointer or reference is used. This is the default for all methods in C++, C, or Object Pascal.Late binding. The type of the instance is determined in the run time. It follows that the actual type of the instance is used and the method of this type is called. This is always used for the methods in Java. In C++, the virtual keyword denotes the methods using the late binding.Late binding gives the class polymorphic behavior. On the other hand, late binding is less effective than early binding, even though the difference may be negligible. (In C++ on PCs, the difference between the late and the early binding is usually one machine instruction per method call.)Any method that might be overridden in any of the derived classes should use the late binding.Note:In C++ and other OOP languages in which the late binding must be declared, the classes containing at least one virtual method are called polymorphic classes. Classes without any virtual method are called non-polymorphic classes. In languages like Java, where all the methods use late binding by default, all the classes are polymorphic.


Why does C plus plus allows static binding and not dynamic binding?

Dynamic binding, or late binding, is when the object code for the class does not get loaded into memory until it is needed. This saves time at module load time, at the cost of delayed execution for the first invocation.


What is the difference between static memory versus dynamic memory?

Dynamic memory can be declared at run-time using the new and delete operators (or malloc and free in C), while static memory must be declared at compile-time.


What is Dynamic Linkage?

Dynamic linkage is the process of connecting external libraries or modules to a program at runtime, allowing the program to access functions and resources from these external sources as needed. This linkage occurs after the program has started execution, providing flexibility and minimizing memory usage by only loading the necessary libraries when required.


What are different static and dynamic features of oops?

static feature are aspects of a program that are fixed at compile time dynamic feature can change at run time the static and dynamic is manifested in oo language in number of diff ways.we consider 1.static and dynamic typing 2." " " classes 3." " " method binding