3.
What is the relation between hashset and hashmap?

7.
What will be the output of the following Java program?
import java.util.*; 
class Output 
{
    public static void main(String args[]) 
    { 
        TreeSet t = new TreeSet();
        t.add("3");
        t.add("9");
        t.add("1");
        t.add("4");
        t.add("8"); 
        System.out.println(t);
    }
}

8.
What will be the output of the following Java program?
import java.util.*;
class Array 
{
    public static void main(String args[]) 
    {
        int array[] = new int [5];
        for (int i = 5; i > 0; i--)
            array[5-i] = i;
        Arrays.fill(array, 1, 4, 8);
        for (int i = 0; i < 5 ; i++)
            System.out.print(array[i]);
    }
}

9.
What will be the output of the following Java code?
import java.util.*;
class hashtable 
{
    public static void main(String args[]) 
    {
        Hashtable obj = new Hashtable();
        obj.put("A", new Integer(3));
        obj.put("B", new Integer(2));
        obj.put("C", new Integer(8));
        obj.clear();
        System.out.print(obj.size());
    }
}

Read More Section(Collections Framework in java)

Each Section contains maximum 100 MCQs question on Collections Framework in java. To get more questions visit other sections.