FYI, a few basic rules to remeber
Reference conversion and casting happen at both compile and
run time. Conversion is up the inheritance tree. Casting is
down inheritance tree. Apply common sence.
Object Reference conversion ( at compile time)
1. interface oldtype may convert to newtype. if newtype is a superinterface of oldtype.
2. class oldtype may be converted to newtype. if newtype is a superclass of oldtype.
3. array oldtype may be converted to newtype. if both types are arrays contain object references and #2 above applies.
Object Reference casting ( at compile time)
4. interface oldtype can always be cast to newtype. if newtype is a non-final object.
5. class oldtype may be cast to newtype. if newtype is a subclass of oldtype
6. array oldtype may be cast to newtype. if if both arrays contain object references and #5 above applies.
* the class type for an object can NOT be determined at compile time.
Object Reference casting ( at run time)
7. if newtype is a class. the newtype must inherit from oldtype.
8. if newtype is an interface. the class of the expression being implemented must implement newtype.
Hope this clear up any outstanding issues.
[This message has been edited by monty6 (edited May 24, 2000).]
[This message has been edited by monty6 (edited May 24, 2000).]
[This message has been edited by monty6 (edited May 24, 2000).]