Wednesday, 30 August 2017

Oops Concepts – Polymorphism

What is Polymorphism ?
In Polymorphism ‘poly’ means ‘many’ and ‘morph’ means ‘forms’ so polymorphism means many forms.
Basically There are two types of Polymorphism
  1. Compile Time Polymorphism
  2. Run Time Polymorphism
Compile Time Polymorphism 
It is also known as ‘Static Polymorphism’ or ‘Early Binding’ or ‘Method Overloading’.
In Method Overloading or Compile Time polymorphism or Static Polymorphism we create multiple methods with same name but with different signatures.
Run Time Polymorphism 
It is also known as ‘Dynamic Polymorphism’ or ‘Late Binding’ or ‘Method Overriding’.
In Method Overriding or Run Time Polymorphism or Dynamic Polymorphism we create method in base class & we can override same method in derived class using ‘Virtual’ or ‘Override’ keywords.
There are two ways or doing
  1. Virtual Functions
  2. Abstract Class

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...