Exam 1z0-816 All QuestionsBrowse all questions from this exam
Question 28

Given:

and:

Which code, when inserted on line 10, prints the number of unique localities from the roster list?

    Correct Answer: A

    To print the number of unique localities from the roster list, the code should transform the stream of Employee objects into a stream of localities, remove duplicates, and then count them. The correct transformation is achieved by using the map method to extract the locality, followed by distinct to remove duplicates, and count to get the number of unique elements. Therefore, option A is correct because it uses map to get the locality of each Employee, distinct to remove duplicates, and count to count the unique localities.

Discussion
Sa16253748596Option: A

A is true.