Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 131

Given:

What is the result?

    Correct Answer: B

    The provided code will iterate through the arrays and insert key-value pairs into the HashMap. HashMap allows both null keys and null values. The pairs ("1", "a"), ("2", "b"), (null, "c"), and ("3", null) are inserted. When retrieving the values, it will output 'a', 'b', 'c', followed by 'null' at the end as the last value associated with the key "3" is null.

Discussion
OmnisumemOption: B

Tested: B.

d7bb0b2Option: B

var map = new HashMap<>(); String k[] = {"a", "b", null, "c"}; String v[] = {"1", "2", "3", null}; for (int i = 0; i < k.length; i++) { map.put(k[i], v[i]); System.out.println(map.get(k[i])); } // 1,2 ,3 , null hasmap accept null as value and key Treeset (add method not put), TreeMap, Hashtable CopyOnWriteArraySet|List ConcurrentHashMap, ConcurrentSkipListSet y ConcurrentSkipListMap no acept null

[Removed]Option: B

B is correct. HashMap can take both null values and keys

StavokOption: B

a b c null