You can store a child object in a parent-type variable. This is the core mechanic of polymorphism.
Animal myPet = new Dog("Rex");
myPet.eat();
myPet.speak();
The variable myPet is declared as Animal, but the actual object in memory is a Dog. Java allows this because every Dog is an Animal. This is called an is-a relationship.
There's a tradeoff. The compiler only lets you call methods that Animal defines. Even though the object is a Dog, you can't call myPet.bark() if bark() isn't in Animal. The compiler checks the declared type, not the actual object.
This restriction exists because the compiler can't always know the runtime type. The variable might hold a Dog now, but a Cat later.