Here are some basic rules to keep in mind when casting variables: Casting an object from a subclass to a superclass doesn't require an explicit cast. Casting an object from a superclass to a subclass requires an explicit cast. The compiler will not allow casts to unrelated types.