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

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 given code filters the elements of the list that contain the digit '1' and then sorts them. The filtered elements are '100, Robin, HR' and '101, Peter, HR'. After sorting, they remain in the same order because '100' comes before '101'. Hence, the output will be '100, Robin, HR' followed by '101, Peter, HR'.

Discussion
DestroyerOption: A

Answer is A

InnovationOption: A

A is correct 100, Robin, HR 101, Peter, HR

asdfjhfgjuaDCVOption: A

A is the correct answer 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); } }

iSnoverOption: A

A is correct, prints "100, Robin, HR 101, Peter, HR". Tested.

steefaandOption: A

A is correct.