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

Given the code fragment:
List<String> 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?
A. listVal.stream().filter(x -> x.length()>3).count()
B. listVal.stream().map(x -> x.length()>3).count()
C. listVal.stream().peek(x -> x.length()>3).count().get()
D. listVal.stream().filter(x -> x.length()>3).mapToInt(x -> x).count()

Download Printable PDF. VALID exam to help you PASS.

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

  1. I have taken the exam last week and I can tell you that most of the questions here DO come up on the exam. But, you must be very carefull. Some of them are slightly modified and the answers are not the same, or if they are not modified the possibility exists that the order of the answers is changed. Very usefull to know the answers ahead anyway!

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.