About Question com.enthuware.ets.scjp.v6.2.85 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
shkolnik
Posts: 8
Joined: Tue Oct 25, 2011 10:46 am
Contact:

About Question com.enthuware.ets.scjp.v6.2.85 :

Post by shkolnik »

Code: Select all

 public String toString(){ return name; }; 
Please correct above line

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

Re: About Question com.enthuware.ets.scjp.v6.2.85 :

Post by admin »

There is nothing wrong with it. (The extra semicolon at the end is not required but is not invalid.)

ETS User

Re: About Question com.enthuware.ets.scjp.v6.2.85 :

Post by ETS User »

I was thrown off by the do{}while(); loop.
If the q.offer(new Person("Pope"));q.offer(new Person("John")); is commented, then there is a runtime exception with the code, because "do" execs before "while" checks the condition.

Turns out your answer is correct, but code is not well-written

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

Re: About Question com.enthuware.ets.scjp.v6.2.85 :

Post by admin »

ETS User wrote: Turns out your answer is correct, but code is not well-written
Not sure why you think so. If you comment out important parts of any code, it will bomb :)

But seriously, you will find tricky code in the exam as well. The fact that some code is not well written, contributes to weird behavior of the code that you should be able to figure out. That is one of the aspects on which you will be tested.
HTH,
Paul.

rgrgrg

Re: About Question com.enthuware.ets.scjp.v6.2.85 :

Post by rgrgrg »

The answer: "It will print : Helped : Pope Helped : John" would be correct, if we use "print" but not "println" in method "helpPeople". Am I wrong?

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests