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

Given the code fragment:

List listVal = Arrays.asList("Joe", "Paul", "Alice", "Tom");

System.out.println (

// line n1

);

Which code fragment, when inserted at line n1, enables the code to print the count of string elements whose length is greater than three?

    Correct Answer: A

    To count the number of string elements in the list where the length of each string is greater than three, you can use the stream API in Java. The filter method is used to include only elements that meet the specified condition, and the count method returns the number of elements in the stream. The correct code fragment is: listVal.stream().filter(x -> x.length()>3).count().

Discussion
DestroyerOption: A

Answer is A

WilsonKKerllOption: A

Answer is A.

InnovationOption: A

A, tested

asdfjhfgjuaDCVOption: A

A is the correct answer

steefaandOption: A

A is correct.

r1muka5Option: A

Correct answer is A.

YasinGaberOption: A

Answer is A and output is 2: List<String> listVal = Arrays.asList("Joe", "Paul", "Alice", "Tom"); System.out.println ( listVal.stream().filter(x -> x.length()>3).count() );