One way I simplify this ordeal of casting ( and reference assignment ) is by thinking about these classes as though they are something real. Believe me, it helps.
To help you begin with, just replace those Base{} , Sub{}, Derived{} names with something more meaningful without losing the relations.
<PRE>
class Fruit{} // better than Base
!
class Apple extends Fruit{} // Better than Derived!
class RedApple extends Apple{} // Better than derived2!
class Grape extends Fruit{} // Better than Sub2!
</PRE>
Once you have done this translation in your mind, think about the
choics given.
Can Grape be cast to Apple? Fruit can be Grape,Apple, or RedApple right? How about a RedApple reference being assigne to Apple? What happens at runtime if you say AppleObj=(Apple)GrapeObje?.......... Might sound funny, but with a little practice you will find this a very convenient and quite an enjoyable way to solve the casting issues. After all, this is what Object Oriented programming is all about. A design
philosophy that can represent the real world relations.
Enjoy Casting......
Ajith