41.
What will be the output of the following Java code?
import java.util.*;
class Bitset 
{
    public static void main(String args[])
    {
        BitSet obj = new BitSet(5);
        for (int i = 0; i < 5; ++i)
            obj.set(i);
        obj.clear(2);
        System.out.print(obj.length() + " " + obj.size());
    }
}

42.
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.sort(array);
        for (int i = 0; i < 5; ++i)
          System.out.print(array[i]);;
    }
}

45.
What will be the output of the following Java program?
import java.util.*;
class Linkedlist 
{
    public static void main(String args[]) 
    {
        LinkedList obj = new LinkedList();
        obj.add("A");
        obj.add("B");
        obj.add("C");
        obj.removeFirst();
        System.out.println(obj);
    }
}

46.
What will be the output of the following Java code?
import java.util.*;
class vector 
{
    public static void main(String args[]) 
    {
        Vector obj = new Vector(4,2);
        obj.addElement(new Integer(3));
        obj.addElement(new Integer(2));
        obj.addElement(new Integer(5));
        obj.removeAll(obj);
        System.out.println(obj.isEmpty());
    }
}

47.
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.remove(new String("A"));
        System.out.print(obj);
    }
}

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.