Because the question states,
"Multiple threads need to access this information but none of them changes it."
This statement indicates that a Hashtable is not required.
Hashtable is synchronized, whereas HashMap is not.
In the scenario stated, synchronization is not required.
Please confirm.
About Question enthuware.ocpjp.v7.2.1368 :
Moderator: admin
-
- Posts: 77
- Joined: Sun Jun 30, 2013 10:04 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1368 :
That is correct. That is why the correct answer is option 2, HashMap.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 39
- Joined: Thu Jan 29, 2015 4:49 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1368 :
When the loading and the accessing the data happens in same time, then the answer is Hashtable.
-
- Posts: 3
- Joined: Tue Nov 05, 2019 6:22 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1368 :
The question also states:
"Which class would be the most appropriate to store such data if the values need not be kept in a sorted fashion?"
Based on this "wrong" clue I have chosen my answer TreeMap, otherwise HashMap was the clear choice. You even mention this in the explanation:
"TreeMap is used to keep the keys sorted which makes it a little bit slower than HashMap. "
So the question and the explanation is a bit ambiguous and contradictory!
"Which class would be the most appropriate to store such data if the values need not be kept in a sorted fashion?"
Based on this "wrong" clue I have chosen my answer TreeMap, otherwise HashMap was the clear choice. You even mention this in the explanation:
"TreeMap is used to keep the keys sorted which makes it a little bit slower than HashMap. "
So the question and the explanation is a bit ambiguous and contradictory!
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1368 :
The statement says, "...need NOT be sorted...".
-
- Posts: 3
- Joined: Tue Nov 05, 2019 6:22 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1368 :
Must have been really tired to have missed that 
P.S. I've taken and passed the exam yesterday. Big thanks to the entire team at EnthuWare.

P.S. I've taken and passed the exam yesterday. Big thanks to the entire team at EnthuWare.

Who is online
Users browsing this forum: No registered users and 8 guests