answersLogoWhite

0

There is Static binding and also Dynamic binding. The compiler has to choose from one or the other. Stactic binding defines the properties of the variables at compile time. Therefore, they can't be changed. In dynamic binding the properties of the variables are determined at runtime. Since the variables can change in form, dynamic binding is more flexible but slower. A great example is given in wikipedia it states: Suppose all life-forms are mortal. In object oriented programming, we can say that the Person and Plant classes must implement the Mortal interface, which contains the method die(). Persons and Plants die in different ways; for example, Plants do not have hearts that stop. Dynamic binding is the practice of figuring out which method to invoke at runtime. For example, if we write void kill(Mortal m) { m.die(); } it's not clear whether m is a Person or a Plant, and thus whether Plant.die() or Person.die() should be invoked on the object. With dynamic binding, the m object is examined at runtime, and the method corresponding to its actual class is invoked.

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
JudyJudy
Simplicity is my specialty.
Chat with Judy
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra

Add your answer:

Earn +20 pts
Q: Advantages of dynamic binding
Write your answer...
Submit
Still have questions?
magnify glass
imp