About declaration of stack object

we can also create reference of child class and object also in child class as: DynamicStack stack=new DynamicStack();

so why sir created the reference of parent class?
as, StackUsingArray stack=new DynamicStack();

is it for some specific reason or just normal?

This here is a classic example of runtime polymorphism.
When both the parent and the child share data variables/methods and we want to access the value from a particular class, we reference it from the object from that class. Now since the parent class can access both itself as well as an object class, we can use its reference when we need data from the parent class(StackUsingArray) and the reference from the child class when we need data from the child class(DyanmicStack). This is runtime polymorphism. Java compiler decides at runtime the value to associate with a variable based on the reference provided.

class Parent { 
    int value = 1000; 
    Parent() { 
        System.out.println("Parent Constructor"); 
    } 
} 
  
class Child extends Parent { 
    int value = 10; 
    Child() { 
        System.out.println("Child Constructor"); 
    } 
} 
public class Main {
    public static void main(String args[]) {
        Child obj=new Child(); 
        System.out.println("Reference of Child Type :" + obj.value);
        Parent par = obj;
        System.out.println("Reference of Parent Type : " + par.value);
    }
}

As an example, try running this program and see the output.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.