Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1037 :

Posted: Fri Jan 20, 2017 8:54 am
by uqzma1xg
about answer D, how it's legal?
variable o3 might not have been initialized

Code: Select all

interface I1 { }
interface I2 { }
class C1 implements I1 { }
class C2 implements I2 { }
class C3 extends C1 implements I2 { }
C1 o1;
C2 o2;
C3 o3;
Which of these statements are legal?
  • Select 3 options
    A. class C4 extends C3 implements I1, I2 { }
    B. o3 = o1;
    C. o3 = o2;
    D. I1 i1 = o3; I2 i2 = (I2) i1;
    E. I1 b = o3;

Re: About Question enthuware.ocajp.i.v7.2.1037 :

Posted: Fri Jan 20, 2017 9:23 am
by admin
The question is only asking about legality of the assignments. You need to assume that there is no other issue involved. Otherwise, there is no class and no method given for the declarations of o1, o2, and o3. Nothing will compile.