Question: I want to understand this:

```
ParentClass p=new ChildClass(); 
//Here ChildClass extends ParentClass

```

Is `p` object of `ParentClass` or of `ChildClass`?

Answer: 
> 
> Is p object of ParentClass or of ChildClass?
> 
> 
> 

`p` is an instance of `ChildClass`. Any instance of `ChildClass` is also an instance of `ParentClass`. The other way around is not true.

**EDIT:**

If you were to call `p.getClass()`, that will return `ChildClass`.
P is a reference in the stack of type ParentClass pointing to a childClass instance in the heap ,this enables you to just call class members defined in ParentClass and take advantage of Polymorphism on runtime through method overriding.