What is the output of the Java code Map<String, Integer> m = new HashMap<>(); m.put(“a”, 1); m.put(“a”, 2); System.out.println(m.size() + ” ” + m.get(“a”));?
Correct answer B. 1 2
Subject / 929 questions
Page 14 of Programming multiple-choice questions with answers. Tap an option to check yourself.
Page 14 of 47
Correct answer B. 1 2
Correct answer C. At most one
Correct answer C. They must be the same
Correct answer A. [10, 30]
Correct answer C. An UnsupportedOperationException is thrown
Correct answer C. Type errors are caught at compile time and casts are avoided
Correct answer C. Type arguments must be reference types
Correct answer B. Number n = x.get(0);
Correct answer B. Generic types are invariant in their type argument
Correct answer C. true
Correct answer B. T item = new T();
Correct answer D. NullPointerException
Correct answer D. throws
Correct answer C. F1
Correct answer C. 2
Correct answer C. The code fails to compile
Correct answer C. In the reverse order of their declaration
Correct answer A. start()
Correct answer A. join()
Correct answer D. cat