Choice:
A. program print nothing
B. [][]{}
C. true[]{}
D. true[xyz]true
E. [xyz][xyz]{10=xyz}
F. true[xyz]null
G. code does not compile
H. code compiles but throw runtime exceptions.
Explain: Supplier functional interface takes no parameter, returns an object of the defined type. Line 5 declared a Supplier returns an object of type Set<String>. HashSet::new and () -> new HashSet<String>() are method reference and corresponding lambda function. Line 9 defined a Supplier returns an object of type Map<Integer, String>. Supplier functional interface defined the method get(), which is used to get the object supplied by the supplier. An empty HashSet<Object> print a [], an empty HashMap<Integer, String> print a {}. At line 6, s1.get() returns an empty HashSet<String>, at line 7, s.add("xyz") added an element to the set, function Set's add() function returns true or false. At line 8, print(s) calls HashSet's toString() and print [xyz]. At line 10, s2.get() returns an empty TreeMap<Integer, String>. However, TreeMap and HashMap are not compatible. Printing.java:10: error: incompatible types: Map<Integer,String> cannot be converted to HashMap<Integer,String>. Map's method put() Adds or replaces key/value pair. Returns previous value or null.