Which of the answer choices are valid given the following declaration?
Map<String, Double> map = new HashMap<>();
E.
Trick question! The Map interface uses put()
rather than add()
to add elements to the map.
If these examples used put()
, the answer would be A and C.
B is no good because a long cannot be shoved into a Double.
D is no good because a char is not the same thing as a String.