Question: What is the result of running the following program?
1 import java.util.*;
2 public class Products {
3 private class Item<T> {}
4 Map<Map<String, String>, Map<String, Set<Item<String>>>> products = new HashMap<>();
5 public static void main(String...args) {
6 Products pds = new Products();
7 pds.test();
8 }
9 private void test() {
10 HashMap<String, String> a = new HashMap<>();
11 a.put("1","2");
12 HashMap<String, Set<Item<String>>> b = new HashMap<>();
13 Set<Item<String>> l = new HashSet<>();
14 l.add(new Item<String>());l.add(new Item<String>());
15 b.put("sports",l);
16 products.put(a,b);
17 System.out.println(products.get(a).get("sports").size());
18 }
19 }
Choice:
A. compiler error at line 3
B. compiler error at line 4
C. compiler error at line 12
D. compiler error at line 13
E. compiler error at line 15
F. compiler error at line 17
G. code compiles but throw runtime exception
H. 2
Next Question