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

Given the code fragment:

List empDetails = Arrays.asList("100, Robin, HR", "200, Mary, AdminServices","101, Peter, HR"); empDetails.stream()

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

.sorted()

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

What is the result?

    Correct Answer: C

    The output will be filtered to include only the strings that contain the letter 'r', which are '100, Robin, HR', '101, Peter, HR', and '200, Mary, AdminServices'. After they are filtered, they are sorted lexicographically. The sorted order would be '101, Peter, HR' followed by '200, Mary, AdminServices'. Therefore, the result will be '101, Peter, HR' and '200, Mary, AdminServices'.

Discussion
pul26Option: C

Answer is C, tested

maslac

correct

asdfjhfgjuaDCVOption: C

Answer is c tested. 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("r")) .sorted() .forEach(System.out::println); } }

steefaandOption: C

C is correct.

WilsonKKerllOption: C

Answer is C.