Classes Hierarchy and Casting between Objects
问题 as far as i know it's not possible to cast an Object of a superclass into an Object of a subclass . This will compile but during runtime it will return an error. More specifically, given the following Hierarchy of Classes and Interfaces: . Alpha is a superclass for Beta and Gamma . Gamma is a superclass for Delta and Omega . Interface "In" is implemented by Beta and Delta In this scenario i define the following code: Delta r; Gamma q; Is this correct? r = (Delta) q; Can i cast q to type Delta