Let's look at an example. Suppose we have this class hierarchy:
Now we have some code:
The cast to Object is redundant but it works. The cast to Yogesh is a problem because Yogesh is a subclass of Person. By contrast, the following case is fine.
So we can see from this that the actual object type must be a match or a supertype of the what we are casting to. In the first example, Person has Object as a supertype so is good but Yogesh as a subclass so not good.