Site Search:

OCPJP Simulation Test 105

<Back to OCPJP





Question: What is the result of the following program?

  1 import java.util.function.*;
  2 import java.util.*;
  3 public class Test {
  4   public static void main(String...args) {
  5     Consumer<String> c1 = System.out::print;
  6     c1.accepts("printme");
  7     Supplier<Queue<String>> s2 = LinkedList::new;
  8     Queue<String> queue = s2.gets();
  9     Consumer<String> c = queue::offer;
 10     c.accepts("first entry");
 11     System.out.print(queue);}}


Choice:
A. []
B. print nothing
C. printmefirst entrynull
D. printme[first entry]
E. [first entry]
F. first entry
G. compile error
H. runtime exception