In the lines above, you have an Animal object, and by casting it to a Dog object, you tell the compiler: "Look, I have this object here, and
you should treat it as an instance of class Dog".
This can only work if the object really
is a Dog object. If the object you're casting isn't a Dog object, you'll get a ClassCastException when you run the code. Casting does not magically convert one type of object to a different type of object.