Search This Blog

Friday, 20 July 2012

What is Polymorphism?


  • Polymorphism is one of the primary characteristics (concept) of object-oriented programming.
  • Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details.
  • Polymorphism is the characteristic of being able to assign a different meaning specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
  • Polymorphism is the ability to process objects differently depending on their data types.
  • Polymorphism is the ability to redefine methods for derived classes.

Types of Polymorphism

  • Compile time Polymorphism
  • Run time Polymorphism

Compile time Polymorphism

  • Compile time Polymorphism also known as method overloading
  • Method overloading means having two or more methods with the same name but with different signatures

Example of Compile time polymorphism

 

Run time Polymorphism

  • Run time Polymorphism also known as method overriding
  • Method overriding means having two or more methods with the same name , same signature but with different implementation

Example of Run time Polymorphism






PREVIOUS CHAPTER
NEXT CHAPTER

No comments:

Post a Comment