MAP Java (GATE - CS)

Concept-based questions on Java Map interface and its implementations (HashMap, TreeMap, LinkedHashMap, ConcurrentHashMap, Hashtable) for GATE Computer Science preparation

12 Questions Published

Questions

Question 1 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 2 Multiple Choice (Single Answer)

Which of the following methods is present in Map interface in Java collections framework?

  1. containsKey(object)
  2. containValue(object)
  3. getKey(object)
  4. keysSet(object)
  5. removeKey(object)
Question 3 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 4 Multiple Choice (Single Answer)

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

  1. putAll(map : m)
  2. Get(key : K)
  3. isEmpty()
  4. removeLast()
  5. put(Key : K, Value : V)
Question 5 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 6 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 7 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 8 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 9 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 the above
Question 10 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 11 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 12 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()