Page 1 of 1

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

Posted: Sun Mar 25, 2012 2:36 pm
by ETS User
Look at this question
class A {
public int getCode(){ return 2;}
}

class AA extends A {
public void doStuff() {
}

public static void main(String[] args) {
A a = null;
AA aa = null;

a =(AA) aa;
a = new AA();

}
}


Given the following two declarations, which of the options will compile?
A a = null;
AA aa = null;


Answers:
a = (AA) aa; Correct - Agreed
a = new AA(); Correct - Agreed
((AA) a).doStuff(); Correct - Agreed
aa = (AA) a; Incorrect - Not agreed

This questiondoes not ask if the code inserted must run without errors, so the option 3 is compilable but not runnable. The option 4 is compilable and not runnable too, and still wrong. Can anyone clarify it to me please?

Thanks.

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

Posted: Sun Mar 25, 2012 7:46 pm
by admin
You are right option 4 should be marked correct. The comment on the option explains it correctly but it is wrongly marked as incorrect.

This will be fixed asap.

thank you for your feedback!