1.

Write a note on polymorphism and dynamic binding.

Answer»

Polymorphism:

In object-oriented programming, polymorphism is a generic term that means ‘many shapes’, (from the Greek meaning “having multiple forms”). Polymorphism is briefly described as “one interface, many implementations.” There are two types of polymorphism one is compile-time polymorphism and the other is run time polymorphism.
For example, consider the operation of addition.

  • If the operands are strings, then the operation would produce a third-string by concatenation.
  • If the operands are numbers, it will generate a sum by dynamic binding.
  • It refers to the linking of a procedure call to the code to be executed in response to the call.
  • Dynamic binding means, that the code associated with a given procedure call is not known until the time of the call at run time.
  • It is associated with polymorphism and inheritance.


Discussion

No Comment Found