How to cast between objects? How about interfaces?
• Upper cast from subclass to supercalss, no need to cast, since the ISA relationship. OakTree is a Tree. • Down cast from superclass to subclass, an explicit cast is needed to avoid compile time error. If you cast Tree to OakTree, it would possibly be right, but not necessarily, since this particular Tree actually might be an AppleTree. In that case, a ClassCastException will be thrown out at the run time • If you cast between siblings or even irrelevant classes, a compile time error results, since compiler has the type information of them. for example, if you cast a OakTree to an AppleTree, or even a Furniture, compile will error out. • However, there is a catch, if you cast to an interface, even they are irrelevant, and compiler might let you go without an error.