Similar Collections


    No collections found

questions

Title
Which of these standard collection classes implements a dynamic array

Which of these standard collection classes implements a dynamic array?


  1. AbstractList
  2. LinkedList
  3. ArrayList
  4. AbstractSet
discuss
Which of these class can generate an array which can increase and decrease in size automatically

Which of these class can generate an array which can increase and decrease in size automatically?


  1. ArrayList()
  2. DynamicList()
  3. LinkedList()
  4. MallocList()
discuss
Which of these method can be used to increase the capacity of ArrayList object manually

Which of these method can be used to increase the capacity of ArrayList object manually?


  1. Capacity()
  2. increaseCapacity()
  3. increasecapacity()
  4. ensureCapacity
discuss
Which of these method of ArrayList class is used to obtain present size of an object

Which of these method of ArrayList class is used to obtain present size of an object?


  1. size()
  2. length()
  3. index()
  4. capacity()
discuss
Which of these methods can be used to obtain a static array from an ArrayList object

Which of these methods can be used to obtain a static array from an ArrayList object?


  1. Array()
  2. covertArray()
  3. toArray()
  4. covertoArray()
discuss
Which of these method is used to reduce the capacity of an ArrayList object

Which of these method is used to reduce the capacity of an ArrayList object?


  1. trim()
  2. trimSize()
  3. trimTosize()
  4. trimToSize()
discuss
What is the output of this program

What is the output of this program

    import java.util.*;
    class Arraylist 
    {
        public static void main(String args[]) 
        {
            ArrayList obj = new ArrayList();
            obj.add("A");
            obj.add("B");
            obj.add("C");
            obj.add(1, "D");
            System.out.println(obj);
        }
    }

  1. [A, B, C, D].
  2. [A, D, B, C].
  3. [A, D, C].
  4. [A, B, C].
discuss
What is the output of this program

What is the output of this program

    import java.util.*;
    class Output 
    {
        public static void main(String args[]) 
        {
            ArrayList obj = new ArrayList();
            obj.add("A");
            obj.add(0, "B");
            System.out.println(obj.size());
        }
    }

  1. 0
  2. 1
  3. 2
  4. Any Garbage Value
discuss
Map implements collection interface

Map implements collection interface?


  1. True
  2. False
discuss
Which of the below does not implement Map interface

Which of the below does not implement Map interface?


  1. HashMap
  2. Hashtable
  3. EnumMap
  4. Vector
discuss
What is the premise of equality for IdentityHashMap

What is the premise of equality for IdentityHashMap?


  1. Reference equality
  2. Name equality
  3. Hashcode equality
  4. Length equality
discuss
What happens if we put a key object in a HashMap which exists

What happens if we put a key object in a HashMap which exists?


  1. The new object replaces the older object
  2. The new object is discarded
  3. The old object is removed from the map
  4. It throws an exception as the key already exists in the map
discuss
While finding the correct location for saving key value pair, how many times the key is hashed

While finding the correct location for saving key value pair, how many times the key is hashed?


  1. 1
  2. 2
  3. 3
  4. unlimited till bucket is found
discuss
Is hashmap an ordered collection

Is hashmap an ordered collection.


  1. True
  2. False
discuss
If two threads access the same hashmap at the same time, what would happen

If two threads access the same hashmap at the same time, what would happen?


  1. ConcurrentModificationException
  2. NullPointerException
  3. ClassNotFoundException
  4. RuntimeException
discuss
How to externally synchronize hashmap

How to externally synchronize hashmap?


  1. HashMap.synchronize(HashMap a);
  2. HashMap a = new HashMap(); a.synchronize();
  3. Collections.synchronizedMap(new HashMap<String, String>());
  4. Collections.synchronize(new HashMap<String, String>());
discuss
What is the output of below snippet

What is the output of below snippet?

public class Demo
{
  public static void main(String[] args)
  {
  Map<Integer, Object> sampleMap = new TreeMap<Integer, Object>();
  sampleMap.put(1, null); 
  sampleMap.put(5, null); 
  sampleMap.put(3, null); 
  sampleMap.put(2, null); 
  sampleMap.put(4, null); 
 
       System.out.println(sampleMap);
   }
}

  1. {1=null, 2=null, 3=null, 4=null, 5=null}
  2. {5=null}
  3. Exception is thrown
  4. {1=null, 5=null, 3=null, 2=null, 4=null}
discuss
If large number of items are stored in hash bucket, what happens to the internal structure

If large number of items are stored in hash bucket, what happens to the internal structure?


  1. The bucket will switch from LinkedList to BalancedTree
  2. The bucket will increase its size by a factor of load size defined
  3. The LinkedList will be replaced by another hashmap
  4. Any further addition throws Overflow exception
discuss
How can we remove an object from ArrayList

How can we remove an object from ArrayList?


  1. remove() method
  2. using Iterator
  3. remove() method and using Iterator
  4. delete() method
discuss
How to remove duplicates from List

How to remove duplicates from List?


  1. HashSet<String> listToSet = new HashSet<String>(duplicateList);
  2. HashSet<String> listToSet = duplicateList.toSet();
  3. HashSet<String> listToSet = Collections.convertToSet(duplicateList);
  4. HashSet<String> listToSet = duplicateList.getSet();
discuss
total MCQs: 175

MCQs

175

Views

151

Best Answers

299

Points

5