This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Parent P = new Parent(); and Parent P = new Child();
and how the object reference variable 'P' works in each case?
The reference variable works the same in both cases; it contains a value that points to an object on the heap. In the second case, I presume that Child extends Parent, and is therefore a Child object is type-compatible with a reference of the Parent type.