Question 31

A method is declared to take three arguments.
A program calls this method and passes only two arguments. What is the results?
  • Question 32

    Given the code fragments:

    and

    What is the result?
  • Question 33

    Given the code fragment:
    List<String> colors = Arrays.asList("red", "green", "yellow");
    Predicate<String> test = n - > {
    System.out.println("Searching...");
    return n.contains("red");
    };
    colors.stream()
    .filter(c -> c.length() > 3)
    .allMatch(test);
    What is the result?
    Searching...
  • Question 34

    Assume customers.txtis accessible and contains multiple lines.
    Which code fragment prints the contents of the customers.txtfile?
    Stream<String> stream = Files.find (Paths.get (“customers.txt”));
  • Question 35

    Given the code fragments:
    class Employee {
    Optional<Address> address;
    Employee (Optional<Address> address) {
    this.address = address;
    }
    public Optional<Address> getAddress() { return address; }
    }
    class Address {
    String city = "New York";
    public String getCity { return city: }
    public String toString() {
    return city;
    }
    }
    and
    Address address = null;
    Optional<Address> addrs1 = Optional.ofNullable (address);
    Employee e1 = new Employee (addrs1);
    String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not available"; What is the result?