 <p>You want to know the difference in these lines:</p> <pre><code>Base obj1 = new Derived(); Derived obj2 = new Derived(); </code></pre> <p>In both the cases the object constructed is of class <code>Derived</code>but references are different. You are able to use reference of type <code>Base</code> because <code>Derived</code> is also <code>Base</code> (assuming <code>Derived</code> extends <code>Base</code>) hence can be used. But which one should we prefer? The former one because it makes robust design.</p> <p>Consider the Collections Framework in Java which has a <code>List</code> interface and two implementations: <code>ArrayList</code> and <code>LinkedList</code>. We can write our program to use a <code>LinkedList</code> or an <code>ArrayList</code> specifically. But then our code depends on those specific implementations. So we should write our program to depend on the super type, <code>List</code>, instead then our program can work for either of the <code>List</code> implementations. </p> <p>In short this is one rule of OOP design: <code>Program to an interface</code>.</p>