Question: I want to understand this:

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

```

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

Answer: 
p is an instance of `ChildClass` which of type `ParentClass` and 
using p you can call all the methods of ParentClass but you cannot call any method of ChildClass.
Example 

```
public class ParentClass{
public Person(){}
public void p(){
System.out.println("from p()");
}
}

public class ChildClass extends ParentClass{
public void c(){
System.out.println("from c()");
}

public static void main(String[] args) {
ParentClass p = new ChildClass();
ChildClass c = new ChildClass();
p.p(); //possible
p.c(); //not possible
c.c();  //possible
}

```

}
`p` is not instance at all. it is just reference of type `ParentClass` that is pointing to object of `ChildClass` on heap memory.

`Objects` live on heap while references can be on stack memory or in other objects on heap. think `reference` as pointers in c/c++ with some additional functionality. 

Your example is of inheritance where reference of type `ParentClass` can point to `ChildClass` object.