What is the result of the following code?
4: Map m = new HashMap(); 5: m.put(123, "456"); 6: m.put("abc", "def"); 7: System.out.println(m.contains("123"));
E.
This question looks like it is about generics, but it's not.
It is trying to see if you noticed that Map does not have a contains()
method.
It has containsKey()
and containsValue()
instead.
If containsKey()
was called, the answer would be false because the 123 in the list is an Integer rather than a String.