I have a parent class Animal and a child class Dog extends Animal.
Dog dog = new Dog();
Animal animal1 = (Dog) dog;
Animal animal2 = (Animal) dog;
I just learned about downcasting and I'd like to ask what is the purpose of doing downcasting and upcasting at the same time?