Question 21

Which two methods from the java.util.stream.Streaminterface perform a reduction operation?
(Choose two.)
  • Question 22

    Given the code fragment:

    Which is the valid definition of the Course enum?
  • Question 23

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

    Given the code fragments:
    class Caller implements Callable<String> {
    String str;
    public Caller (String s) {this.str=s;}
    public String call()throws Exception { return str.concat ("Caller");}
    }
    class Runner implements Runnable {
    String str;
    public Runner (String s) {this.str=s;}
    public void run () { System.out.println (str.concat ("Runner"));}
    }
    and
    public static void main (String[] args) InterruptedException, ExecutionException {
    ExecutorService es = Executors.newFixedThreadPool(2);
    Future f1 = es.submit (new Caller ("Call"));
    Future f2 = es.submit (new Runner ("Run"));
    String str1 = (String) f1.get();
    String str2 = (String) f2.get();//line n1
    System.out.println(str1+ ":" + str2);
    }
    What is the result?
  • Question 25

    Given:

    What is the result?