Supper class can be used to refer to any sub class but whenever you are trying to cast any object the actual object inside the reference should be same as the object to whom are we casting.
In your case the actual object inside the animal reference is animal itself whenever you are trying to cast it to dog the jvm will complain because the actual object inside the animal is not same as the object in which you are trying to put this after cast (that is dog object).
Think it like 2 glasses one with half the capacity of other. You can use the bigger one to hold the
water that is in smaller one. But you can not hold the water of bigger one in smaller glass (or you will loose half the water and jvm does not allow it
), But if first we put the water of smaller glass into bigger glass then we can pour the water of bigger to smaller any time.
Take the bigger as parent class and smaller as the child class.