Question 151

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?
  • Question 152

    Given:
    class Student {
    String course, name, city;
    public Student (String name, String course, String city) {
    this.course = course; this.name = name; this.city = city;
    }
    public String toString() {
    return course + ":" + name + ":" + city;
    }
    public String getCourse() {return course;}
    public String getName() {return name;}
    public String getCity() {return city;}
    and the code fragment:
    List<Student> stds = Arrays.asList(
    new Student ("Jessy", "Java ME", "Chicago"),
    new Student ("Helen", "Java EE", "Houston"),
    new Student ("Mark", "Java ME", "Chicago"));
    stds.stream()
    .collect(Collectors.groupingBy(Student::getCourse))
    .forEach(src, res) -> System.out.println(scr));
    What is the result?
  • Question 153

    Given the code format:

    Which code fragment must be inserted at line 6 to enable the code to compile?
  • Question 154

    Given the content of the employee.txtfile:
    Every worker is a master.
    Given that the employee.txtfile is accessible and the file allemp.txtdoes NOT exist, and the code fragment:

    What is the result?
  • Question 155

    Which two methods from the java.util.stream.Stream interface perform a reduction operation? (Choose two.)