Collections


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    BalancedTree will improve performance from O(n) to O(log n) by reducing hash collisions.


  1. Which of these standard collection classes implements a linked list data structure?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    LinkedList



  1. What is the output of below snippet?
    import java.util.*;
    public class Map_Example
    {
    public static void main(String[] args)
    {
    Map mapSample = new TreeMap();
    mapSample.put(4, null);
    mapSample.put(0, null);
    mapSample.put(3, null);
    mapSample.put(2, null);
    mapSample.put(1, null);

    System.out.println(mapSample);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    HashMap needs unique keys. TreeMap sorts the keys while storing objects.


  1. Which of these method is used to add an element to the start of a LinkedList object?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    addFirst()



  1. Which of these method of HashSet class is used to add elements to its object?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    add()