Question 56

Given the code fragment:

What is the result?
  • Question 57

    Given:
    IntStream stream = IntStream.of (1,2,3); IntFunction<Integer> inFu= x -> y -> x*y;//line n1 IntStream newStream = stream.map(inFu.apply(10));//line n2
    newStream.forEach(System.output::print);
    Which modification enables the code fragment to compile?
  • Question 58

    Given the code fragments:
    class ThreadRunner implements Runnable {
    public void run () { System.out.print ("Runnable") ; }
    }
    class ThreadCaller implements Callable {
    Public String call () throws Exception {return "Callable"; )
    }
    and
    ExecutorService es = Executors.newCachedThreadPool ();
    Runnable r1 = new ThreadRunner ();
    Callable c1 = new ThreadCaller ();
    // line n1
    es.shutdown();
    Which code fragment can be inserted at line n1 to start r1 and c1 threads?
  • Question 59

    Given:
    public class Customer {
    private String fName;
    private String lName;
    private static int count;
    public customer (String first, String last) {fName = first, lName = last;
    ++count;}
    static { count = 0; }
    public static int getCount() {return count; }
    }
    public class App {
    public static void main (String [] args) {
    Customer c1 = new Customer("Larry", "Smith");
    Customer c2 = new Customer("Pedro", "Gonzales");
    Customer c3 = new Customer("Penny", "Jones");
    Customer c4 = new Customer("Lars", "Svenson");
    c4 = null;
    c3 = c2;
    System.out.println (Customer.getCount());
    }
    }
    What is the result?
  • Question 60

    Given the code fragment:
    String str = "Java is a programming language"; ToIntFunction<String> indexVal = str: : indexOf; //line n1 int x = indexVal.applyAsInt("Java");//line n2 System.out.println(x);
    What is the result?