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

Given the code fragment:

What is the result?

    Correct Answer: B

    The given code uses Java Streams to filter out non-empty strings from the list and then counts them. The `filter(x -> !x.isEmpty())` method is correct and filters out all non-empty strings. After applying this filter to the list `Arrays.asList("", "George", "", "John", "Jim")`, the non-empty strings are "George", "John", and "Jim", which results in a count of 3. Hence, the value of `newVal` will be 3 and it will print 3 without any compilation errors.

Discussion
kartaOption: B

Answer is B

jduarteOption: B

The answer ha is B. Instruction Long newVal= valList.stream().filter(x->!x.isEmpty()).count(); is correct

Svetleto13Option: B

B,tested

asdfjhfgjuaDCVOption: B

B is the answer

steefaandOption: B

B is correct.

YasinGaberOption: B

B, tested, system will print 3, there is no issue with line 2

SamriddjiOption: B

B, tested

SigamaniOption: B

B is correct