Collections

11.Which of the following methods is used to get a synchronized version of a collection?
  • A. Collections.synchronizedCollection()
  • B. Collections.synchronizedMap()
  • C. Collections.synchronizedList()
  • D. All of the above

All of the above

All of the above

12.Which of the following collections allow duplicate values but not duplicate keys?
  • A. HashSet
  • B. ArrayList
  • C. TreeMap
  • D. HashMap

HashMap

HashMap

13.What will be the output of the following?
Map map = new LinkedHashMap<>(); map.put("A", "1"); map.put("B", "2"); map.put("A", "3"); System.out.println(map);
  • A. {A=1, B=2, A=3}
  • B. {B=2, A=3}
  • C. {A=3, B=2}
  • D. {A=1, B=2}

{A=3, B=2}

{A=3, B=2}