About Question enthuware.ocpjp.v7.2.1470 :

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

Moderator: admin

Post Reply
sir_Anduin@yahoo.de
Posts: 62
Joined: Fri Aug 07, 2015 2:16 pm
Contact:

About Question enthuware.ocpjp.v7.2.1470 :

Post by sir_Anduin@yahoo.de »

The produce method simply sets the flag to true and notifies anybody who has called wait.
In your answer you have the procude method set the flag to false
If it is not true, it waits until it is notified by the produce method
in the given anser it will wait if is is true...
If it is true, it simply sets it to false.
if false, the flag is set to true in the given answer.


This statements and answers confuse me, you cou clarify?

Thanks

Aleks

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

Re: About Question enthuware.ocpjp.v7.2.1470 :

Post by admin »

There are actually two correct answers and both are very similar.
Answer 1:
produce() sets the flag to false (signifying that there is nothing to produce anymore) and notifies all.
consume() checks for flag to be true and if the flag is true (implying that something needs to be produced), it waits. if the flag is false (implying there is no need to produce), it sets the flag to true (implying someone needs to produce something).

Answer 2:
produce() sets the flag to true (signifying that something has been produced) and notifies all.
consume() checks for flag to be false (i.e. while( !flag ) ) and if the flag is false implying that production is not ready, it waits. if the flag is true, it sets the flag to false (implying that item has been consumed and someone needs to produce something now).

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Harvey Manfrenjensen
Posts: 14
Joined: Fri May 11, 2018 6:59 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1470 :

Post by Harvey Manfrenjensen »

Should it not be in the explanation

Code: Select all

final ProdCon pc =  new ProdCon();
instead of

Code: Select all

ProdCon pc =  new ProdCon();
?

Regards Paul

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

Re: About Question enthuware.ocpjp.v7.2.1470 :

Post by admin »

Not really. It is effectively final already because none of the anonymous inner classes try to modify it.
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 39 guests