Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - 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:

Stephanie
1 months ago
I thought this was a question about cooking recipes, not Java programming! Guess I need to brush up on my programming skills before the next exam.
upvoted 0 times
Clorinda
6 days ago
I know, I was surprised too! I need to study more for the next exam.
upvoted 0 times
...
Jonell
20 days ago
A) listVal.stream().filter(x -> x.length()>3).count()
upvoted 0 times
...
...
Keneth
1 months ago
Option D looks good, but it's unnecessary to use mapToInt() to convert the String elements to integers. The filter() method alone should do the trick.
upvoted 0 times
...
Lina
2 months ago
Option C is interesting, but the peek() method is used for side effects, not for filtering. It wouldn't give us the correct count.
upvoted 0 times
Jesusa
4 days ago
D) listVal.stream().filter(x -> x.length()>3).mapToInt(x -> x).count()
upvoted 0 times
...
Cortney
9 days ago
That's correct. The filter method will only keep elements with a length greater than 3.
upvoted 0 times
...
Carin
1 months ago
A) listVal.stream().filter(x -> x.length()>3).count()
upvoted 0 times
...
...
Shenika
2 months 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
Johnetta
16 hours ago
User3: Yeah, option A is the right choice. It filters the elements with length greater than three and then counts them.
upvoted 0 times
...
Rocco
3 days ago
User2: I agree with you. Option B is incorrect because map() is for transformation, not filtering.
upvoted 0 times
...
Yasuko
6 days ago
User1: I think option A is correct. It filters the elements based on the length condition and then counts them.
upvoted 0 times
...
Jamal
19 days ago
Yes, using mapToInt() after filter() will give us the count of elements with length greater than three.
upvoted 0 times
...
Alpha
28 days ago
D) listVal.stream().filter(x -> x.length()>3).mapToInt(x -> x).count()
upvoted 0 times
...
Edwin
1 months ago
That makes sense, we want to filter out the elements with length greater than three.
upvoted 0 times
...
Nana
1 months ago
A) listVal.stream().filter(x -> x.length()>3).count()
upvoted 0 times
...
...
Janine
2 months 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
Chu
1 months ago
User2: Yes, you're right. The filter() method is used to filter elements based on the condition x.length() > 3.
upvoted 0 times
...
Paris
2 months ago
User1: I think option A is the correct answer.
upvoted 0 times
...
...
Venita
2 months ago
I'm not sure about the answer. Can someone explain why option A is correct?
upvoted 0 times
...
Elliott
2 months 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
2 months 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
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77