Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 42

Given the code fragment:

List empDetails = Arrays.asList("100, Robin, HR",

"200, Mary, AdminServices",

"101, Peter, HR");

empDetails.stream()

.filter(s-> s.contains("1"))

.sorted()

.forEach(System.out::println); //line n1

What is the result?

    Correct Answer: A

    The code fragment filters the list to only include strings that contain the character '1', which results in '100, Robin, HR' and '101, Peter, HR'. These two strings are then sorted in their natural order, which does not change their order as they are already sorted. Finally, they are printed out. Therefore, the output is '100, Robin, HR' followed by '101, Peter, HR'.

Discussion
jduarteOption: A

Answer A. Tested

WilsonKKerllOption: A

Answer is A.

Sofia_ShireenOption: A

Answer: A

asdfjhfgjuaDCVOption: A

A is the correct answer import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { List<String> empDetails = Arrays.asList( "100, Robin, HR", "200, Mary, AdminServices", "101, Peter, HR" ); empDetails.stream() .filter(s -> s.contains("1")) .sorted() .forEach(System.out::println); } }

steefaandOption: A

Answer is A as String starting with 200 if filtered out since it doesn't contain 1.

r1muka5Option: A

Answer is A