Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle Exam 1Z0-809 Topic 9 Question 27 Discussion

Actual exam question for Oracle's 1Z0-809 exam
Question #: 27
Topic #: 9
[All 1Z0-809 Questions]

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?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Shenika
6 days ago
Option B doesn't seem right because the map() method is used to transform the elements, not to filter them. The count() method would return the number of elements that are true, which is not what we want.
upvoted 0 times
...
Janine
16 days ago
I think option A is the correct answer. The stream() method is used to create a stream of the list elements, and the filter() method is used to filter the elements based on the condition x.length() > 3, which gives us the count of the string elements whose length is greater than three.
upvoted 0 times
...
Venita
16 days ago
I'm not sure about the answer. Can someone explain why option A is correct?
upvoted 0 times
...
Elliott
17 days ago
I agree with Ressie. Option A makes sense as it filters the elements based on length and then counts them.
upvoted 0 times
...
Ressie
18 days ago
I think the answer is A) listVal.stream().filter(x -> x.length()>3).count(). Because it filters out the elements with length greater than three and then counts them.
upvoted 0 times
...

Save Cancel