Hi,
the correct answer to this question is [1, 1, 3],
but how am I supposed to know that numbers will be printed in this particular order?
I mean groupingBy is using HashMap as default Map type and it doesn't guarantee ordering of keys.
Maybe this question needs to be rephrased or TreeMap constructor have to be provided to make it clear.
About Question enthuware.ocpjp.v8.2.1883 :
Moderator: admin
-
- Posts: 11
- Joined: Wed Jun 14, 2017 3:43 am
- Contact:
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1883 :
You are right about order cannot be known. However, notice that there is no option with same elements but different order. There is no option that says "None of the above". Thus, the order is not really important for this question.
Since you know there is exactly one correct option, you should select this option without worrying about the order. This is how you should do in the real exam as well.
HTH,
Paul.
Since you know there is exactly one correct option, you should select this option without worrying about the order. This is how you should do in the real exam as well.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 112 guests