Knowledge Management Banner

Knowledge Management Banner

c# : Inheritance Polymorphism : Part 7

Inheritance
  • It is generally used when the codes in the class are mostly common.
  • Same code in two class should be removed and formed as third class.
  • The uncommon code will remain as it is in previous two class and these two class will be inherited from the third class
  • Thus all the functions and the properties in third class will be available in first two class.

Polymorphism
  • Single object has many forms, one name many forms
e.g.
  • Teachers behaves with student
  • Teachers behaves with senior
  • Teacher, here has different attitude
Static / Compile time polymorphism
  • If a class has two method with same name with different types of passed parameters, than the method to be invoke depends on compile time.
  • Method overloading can be an example of static polymorphism
Dynamic / runtime polymorphism
  • Over riding the method of a base class in the derived class which is done at run time is called dynamic polymorphism.
  • Method overriding can be an example of dynamic polymorphism.





No comments

Powered by Blogger.