Java Collections Framework

Questions about Java Collections Framework classes, interfaces, constructors, and methods

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following methods cannot be invoked with the object of ConcurrentHashMap class?

  1. putIfAbsent(K key, V value)
  2. replace(K key, V oldValue, V newValue)
  3. replace(K key, V value)
  4. containsValue(Object value)
  5. None of these
Question 2 Multiple Choice (Single Answer)

Which of the following methods cannot be invoked with the Object of TreeMap Constructor?

  1. descendingMap()
  2. firstEntry()
  3. floorEntry(K key)
  4. headMap(K toKey)
  5. fixedMap()
Question 3 Multiple Choice (Single Answer)

How many constructors of HashTable Class are there in java collections framework?

  1. 6
  2. 5
  3. 4
  4. 3
  5. 2
Question 4 Multiple Choice (Single Answer)

Which of the following methods can be invoked from the object of TreeMap Constructor?

  1. higherEntry(K key)
  2. pollLastEntry()
  3. descendingKeySet()
  4. Both (1) and (3)
  5. All of these
Question 5 Multiple Choice (Single Answer)

Which of the following methods is present in the PriorityQueue class in Java?

  1. poll()
  2. offer(E e)
  3. contains(Object o)
  4. Both (1) and (2)
  5. All of these
Question 6 Multiple Choice (Single Answer)

How many constructors of TreeMap are there in java collections framework?

  1. 6
  2. 5
  3. 4
  4. 3
  5. 2
Question 7 Multiple Choice (Single Answer)

Which of the following methods is/are present in the Vector class?

  1. copyInto(array : Object[])
  2. removeFirst()
  3. lastIndexOf(element :e)
  4. addLast(object)
  5. Set(int index, element e)
Question 8 Multiple Choice (Single Answer)

Which of the following methods is not present in the map interface in java collections framework?

  1. containsKey(object)
  2. containsValue(object)
  3. Get(key : K)
  4. Put(key : K, Value : V)
  5. setValue(Value : V)
Question 9 Multiple Choice (Single Answer)

Which of the following methods are not present in Collection interface?

  1. retainAll(Collection<!--?--> c)
  2. containsAll(Collection<!--?--> c)
  3. toArray(T[] a)
  4. firstEntry()
  5. equals(Object o)
Question 10 Multiple Choice (Single Answer)

Which of the following methods is present in map interface in java collections framework?

  1. getKey()
  2. getValue()
  3. setValue(Value : V)
  4. keyset()
  5. getKeys()
Question 11 Multiple Choice (Single Answer)

How many constructors of ConcurrentHashMap class are there in java collections framework?

  1. 8
  2. 7
  3. 6
  4. 5
  5. 4
Question 12 Multiple Choice (Single Answer)

How many constructors of LinkedHashMap class are there in java collections framework?

  1. 6
  2. 5
  3. 4
  4. 3
  5. 2
Question 13 Multiple Choice (Single Answer)

How many constructors of HashMap class are there in java collections framework?

  1. 6
  2. 5
  3. 4
  4. 3
  5. 2
Question 14 Multiple Choice (Single Answer)

Which of the following methods is present in map interface in java collections framework?

  1. boolean containsKey(object)
  2. containValue(object)
  3. getKey(object)
  4. KeysSet(object)
  5. removeKey(object)
Question 15 Multiple Choice (Single Answer)

Which of the following methods are not present in Map interface?

  1. putAll(map : m)
  2. Get(key : K)
  3. isEmpty()
  4. removeLast()
  5. Put(key : K, Value : V)