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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ETS User

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

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests