interface I1 {}
interface I2 {}
class Base implements I1 {}
class Sub extends Base implements I2 {}
class Yellow {
public static void main(String args[]) {
Base base = new Sub(); // 1
I1 i1 = base; // 2
Sub sub = (Sub)base; // 3
I2 i2 = (Sub)base; // 4
}}
when i say //1 , i mean i am creating an instance of Sub() storing the instance in Base. At runtime, base refers to an instance of Sub class.
If my understanding is right, then Sub does nt implement interface i1.
with base as srcRef and i1 as destRef, i have read,
srcRef can be stored in destRef, only if destRef is a superclass or an interface which is implemented. This is neither the case here. Hence, the
