exam questions

Exam 1z0-829 All Questions

View all questions & answers for the 1z0-829 exam

Exam 1z0-829 topic 1 question 14 discussion

Actual exam question from Oracle's 1z0-829
Question #: 14
Topic #: 1
[All 1z0-829 Questions]

Given:

What is the result?

  • A. {bicycle=7, car=7, motorcycle=7, truck=7}
  • B. {3:bicycle, 0:car, 6:motorcycle, 5:truck}
  • C. Compilation fails.
  • D. {bicycle=1, car=3, motorcycle=1, truck=2}
  • E. {bicycle, car, motorcycle, truck}
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
james2033
Highly Voted 11 months, 3 weeks ago
Selected Answer: D
package q14; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; public class Test { public static void main(String[] args) { List<String> elements = Arrays.asList("car", "truck", "car", "bicycle", "car", "truck", "motorcycle"); Map<String, Long> outcome = elements.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); System.out.println(outcome); } } // Result: // {motorcycle=1, bicycle=1, car=3, truck=2}
upvoted 5 times
...
xplorerpj
Most Recent 7 months, 1 week ago
Selected Answer: D
Correct answer is D
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago