Applications of Inheritance in OOP

Please tell me - What is applications of Inheritance in OOP ? I search on google, stackoverflow but could not get the specific answer…

The main purpose of introducing the inheritance is to “REUSE” your code and in the same way, when you reuse your code it means directly you OPTIMIZE your code and it will reduce your redundancy of your code.

1 Like

Inheritance is one of the fundamental features of object-oriented programming. It’s main uses are to enable polymorphism and to be able to reuse code for different classes by putting it in a common superclass (although it’s not a good idea to create a superclass just for the sake of sharing code - class designs should not break the Liskov substitution principle).

It has basically 2 applications-

  1. Overriding
  2. Code reuse

Regarding code reuse-

Implementation inheritance is the mechanism whereby a subclass re-uses code in a base class

In other words, lets say there is a base class X. Now, we have to make another class Y which uses same/similar implementation as X, then we can simply inherit it from X and continue adding whatever extra we needed to.

Regarding Overriding and more applications, try these-

Applications from WikiPedia
When to use inheritence
What is the use of inheritence

See whichever deems fit to you, in case doubt persists, comment back.

1 Like

Others applications???

Other applications, like, its used to help implementing features like polymorphism. Not a compulsion, but I heard it makes things convenient.

Overriding is a types of polymorphism.

Yup. You want something more, dear?