![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbtbQZYLSSABvjyAYVbFe3NazAin_ZhEug9Ni9gjDommcSkKRHaqpaLDCwryeAaGaSiSsAIcI3HogCmDjk2hIbVIS9D6TlWHKiVhwqJbQxg-n-7MN-0gTmzp6aqpzmWxJ_q-CsapvKaXy0/s1600/Untitled.jpg)
In inheritance a new class is created from an existing class.
The word inheritance means inheriting a feature, property or anything from one to another.
In programming, some codes for one class can be inherited from another class so that coding time can be reduced.
The arrow head indicates from where it is inherited.
So A is inherited from B in the diagram above.
Below shows a real life example of Inheritance:
Here Herbivore, Carnivore and omnivore are inherited from the Animal.
Rabbit is inherited from Herbivore and so on...
![](https://www.rome2rio.com/images/rome2rio-2.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhchTEr4uq6_bY08Z0UN_QskSqNVukTnXCOm5X_hD96M0ec7pTSd2epOTcmWaGTxOX5EICbUC6q0yc5QRH7KtUxvg2xVC2Cuz0txeWDv53uJvLTf4RG9W107IDcpBcsszLuhNpKL1NR9erS/s400/encapsulation-data-procedure-oop.jpg)
Here shows another way of inheritance (multiple inheritance)
Here Omnivore is Inherited from both Herbivore and Carnivore!!
![](https://www.rome2rio.com/images/rome2rio-2.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhchTEr4uq6_bY08Z0UN_QskSqNVukTnXCOm5X_hD96M0ec7pTSd2epOTcmWaGTxOX5EICbUC6q0yc5QRH7KtUxvg2xVC2Cuz0txeWDv53uJvLTf4RG9W107IDcpBcsszLuhNpKL1NR9erS/s400/encapsulation-data-procedure-oop.jpg)
Encapsulation basically means hiding something within another.
Encapsulation is used for hiding the code and data in a single unit to protect the data from the outside world. In programming, Encapsulation is wrapping and hiding properties and methods.
Abstraction refers to showing only the necessary details to the intended user.
Simply, polymorphism means a single action that is done in many different ways. For example in the picture below different animals are saying (perhaps the same thing) in different ways - which is their language.
And in the following picture there are girls and boys. On the 'girl' class and 'boy' class they have dressed differently. On the same class, same gender but their way of dressing is different. This is polymorphism.
Abstract means unrealistic or maybe a summary or anything which is difficult to interpret.
Below are three Abstract pictures. By looking at it we don't really understand what it is.
In software development abstraction can be used for example if you have an new idea of a new part to include in the software but have no idea how to write the exact code for it. Then for this abstract idea you can make a separate abstract class.
In this abstract class only the relevant data about an object will be shown
in order to reduce complexity and to increase efficiency. And everything else will be hidden.
Below are some links which will provide more explanations and examples for OOP concepts..