Let's say I have a GrandParentClass that gets inherited by ParentClass which gets inherited by ChildClass.
Why can I only cast "up the chain" but not down?
Why can I only dynamic bind "down the chain" but not up?
I'm looking for some reasoning I can apply to these questions instead of just memorizing the pattern. I'm really hoping this isn't just a "that's just the way it is" kind of answer.
Example of casting:
ParentClass object = new ParentClass();
System.out.println((GrandParentClass)object); //casting ChildClass throws compiler error
Example of dynamic binding:
GrandParentClass = new ChildClass(); //Switching GrandParentClass with ChildClass throws run time error.