Page 1 of 1
About Question enthuware.ocpjp.v7.2.1101 :
Posted: Tue Mar 31, 2015 2:33 pm
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.
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Tue Mar 31, 2015 7:46 pm
by admin
Because we have seen candidates getting a question on it.
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Wed Apr 01, 2015 3:59 pm
by ThufirHawat
OK...
so, thanks!
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Wed Apr 19, 2017 3:50 am
by nikitos
Could you suggest good information/article that is possible to easy understand for start about happens-before?
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Wed Apr 19, 2017 10:12 am
by admin
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Mon May 15, 2017 3:10 pm
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.
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Mon May 15, 2017 11:31 pm
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.
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Tue May 16, 2017 9:22 am
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?
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Thu Nov 08, 2018 3:40 pm
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.
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Thu Nov 08, 2018 9:54 pm
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.
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Thu Nov 08, 2018 10:28 pm
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!
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Thu Aug 01, 2019 2:07 am
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)
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Fri Aug 02, 2019 7:34 am
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.
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Tue Feb 18, 2020 3:25 am
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?
Re: About Question enthuware.ocpjp.v7.2.1101 :
Posted: Tue Feb 18, 2020 4:57 am
by admin
Correct.