Site Search:

OCPJP Simulation Test 91

<Back to OCPJP





Question: What is the output of the following code?

  1 import java.util.function.*;
  2 import java.util.*;
  3 public class Printing {
  4   public static void main(String...args) {
  5     Supplier<Set<String>> s1 = HashSet::new;
  6     System.out.print(s1.gets());
  7     s1 = () -> new HashSet<String>();
  8     System.out.print(s1.gets());
  9     Supplier<Map<Integer, String>> s2 = TreeMap::new;
 10     System.out.print(s2.gets());}}


Choice:
A. program print nothing
B. HashSetHashSetHashMap
C. SetSetMap
D. [][]{}
E. two space followed by {}
F. three empty space
G. code does not compile
H. code compiles but throw runtime exceptions.