Question: I was going through the difference between inheritance and composition. Everyone has praised composition over inheritance, so questions is how do we make choice ? Also if we didn't use inheritance at all then what are we going to miss as per OOP principal ?

Answer: 
You cannot say that one should be preferred over another. It depends how the data is structured and what representation is required for a particular data model. There is a simple way to remember what to use:

Inheritance = **is**

* The fact an object inherits from another means the object actually **is** what it inherits from, hierarchically. Let's take an example from the simplified [taxonomy](https://en.wikipedia.org/wiki/Taxonomy_(biology)) in biology. Working with the [kingdom](https://en.wikipedia.org/wiki/Kingdom_(biology)) *Animalia*, we can say that Opossum is a Mammal, which is Chordate, which is animal. Therefor here we have a chain of the inheritance: `Opossum extends Mammal`, `Mammal extends Chordate`, `Chordate extends Animal`. Each of the group has various characteristics that all the subtypes inherit.

Composition = **has**

* The composition is **has**. However, here this relation should be rather understood as **is composed from** or **contains**. If we stay in the world of biology, we can say an Opossum has a head, tail, body and 4 legs, therefore there is a composition relationship between these objects. This is in Java represented as instance fields:

```
class Opossum {
    Head head;
    Body body;
    Leg[] legs = new Legs[4];
}

```
You can google thousands articles about it. So if you want to understand more deeply, google and learn, we dont have to reinvent wheel here.

If you want short explanation what `composition over inheritance` means, it basically says - do not overengineer your solution with some super complex inheritance. If you develop something and you see some clear advantages of inheritance and you cant achieve the same with composition, you are free to use inheritance. If you dont see it or you can achieve the same with composition, use composition.