About Question enthuware.ocpjp.v7.2.1101 :

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

Moderator: admin

Post Reply
ThufirHawat
Posts: 28
Joined: Wed Feb 25, 2015 9:03 am
Contact:

About Question enthuware.ocpjp.v7.2.1101 :

Post by ThufirHawat »

Why this question? In the "OCA/OCP Java SE 7 Programmer I & II Study Guide" from Oracle Press, the only mention to this is in page number 801, and nothing detailed, just a small mention with no methods information.

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

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

Post by admin »

Because we have seen candidates getting a question on it.
If you like our products and services, please help us by posting your review here.

ThufirHawat
Posts: 28
Joined: Wed Feb 25, 2015 9:03 am
Contact:

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

Post by ThufirHawat »

OK...
so, thanks!

nikitos
Posts: 21
Joined: Mon Oct 24, 2016 6:55 am
Contact:

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

Post by nikitos »

Could you suggest good information/article that is possible to easy understand for start about happens-before?

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

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

Post by admin »

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

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

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

Post by lenalena »

Just to clarify. In the API for ConcurrentMap - can we assume that unless the API states that the operation is atomic, it is not? For example, computeIfAbsent does not state that it's atomic. So do we assume that it's not?

Thanks.

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

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

Post by admin »

No, it is the reverse. The whole point of creating ConcurrentMap is to provide thread safe operations. The JavaDoc for this interface clearly says at the beginning itself: "A Map providing thread safety and atomicity guarantees."

So unless a method explicit says that it is not atomic, you should assume that it is atomic.

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

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

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

Post by lenalena »

Thank you. That's what I thought originally, however, I was confused by the API that states that specifications for these 3 methods and these three methods alone! explicitly state that they are atomic. I thought it was a bit redundant unless there are some special guarantees.

Also, the explanation for the question for some reason singles out putIfAbsent, remove, and replace methods. Why is that? Is there anything special about them?

MoistCarrot
Posts: 6
Joined: Fri Oct 26, 2018 9:18 pm
Contact:

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

Post by MoistCarrot »

Please correct me if I am wrong; is the last option correct because all the other options are default methods in Map, whereas in ConcurrentMap they are not? For example, if boolean replace(K key, V oldValue, V newValue) was not a default method in both classes (this is a theoretical situation of course) would the answer then be boolean replace(K key, V oldValue, V newValue) instead of None of the above? Thanks.

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

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

Post by admin »

The problem statement ask you about the methods that are provided by ConcurrentMap in addition to the methods provided by Map. So, you have to select the method that is there is in ConcurrentMap but not in Map. None of the methods given in the options are present in Map.

No, it has nothing to do with the method being default but just being declared.
If you like our products and services, please help us by posting your review here.

MoistCarrot
Posts: 6
Joined: Fri Oct 26, 2018 9:18 pm
Contact:

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

Post by MoistCarrot »

Ah okay that makes way more sense. I feel like that question should be reworded differently; but if it is worded like that on the exam then that will be good to know!

dk35840
Posts: 4
Joined: Wed Jun 05, 2019 6:44 am
Contact:

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

Post by dk35840 »

Hey please revise the description with latest java 8

It is a Map providing additional atomic putIfAbsent, remove, and replace methods.

Memory consistency effects: As with other concurrent collections, actions in a thread prior to placing an object into a ConcurrentMap as a key or value happen-before actions subsequent to the access or removal of that object from the ConcurrentMap in another thread.


to

A Map providing thread safety and atomicity guarantees.
Memory consistency effects: As with other concurrent collections, actions in a thread prior to placing an object into a ConcurrentMap as a key or value happen-before actions subsequent to the access or removal of that object from the ConcurrentMap in another thread.



please see it

https://docs.oracle.com/javase/8/docs/a ... nt(K,%20V)

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

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

Post by admin »

Thank you for the feedback!
The statement in the explanation is a general statement saying what kind of methods are there in ConcurrentMap. It is not a statement from the JavaDoc though the second one is.
If you like our products and services, please help us by posting your review here.

bvrulez
Posts: 33
Joined: Sat Feb 15, 2020 12:44 am
Contact:

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

Post by bvrulez »

I am confused. "None of the above" is correct because all other methods are ALREADY on java.util.Map, right? The explanation to the first answer sounds like originally the answer was "A" and it just changed with Java 8, right?

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

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

Post by admin »

Correct.
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 36 guests