Vidyalelo
Java Programming · all questions

Java Collections Framework
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

179

Questions

9/9

Page

Pick an option on a question to see the right answer and solution.

Which of the below does not implement Map interface?

Select an option to see the answer and solution.

Which of these classes provide implementation of map interface?

Select an option to see the answer and solution.

Which of these methods is used to retrieve elements in BitSet object at specific location?

Select an option to see the answer and solution.

Which of these exceptions is thrown by remover() method?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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);
        System.out.print(Arrays.binarySearch(array, 4));
    }
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
class Output 
{
    public static void main(String args[]) 
    {
        ArrayList obj = new ArrayList();
        obj.add("A");
        obj.add("D");
        obj.ensureCapacity(3);
        obj.trimToSize();
        System.out.println(obj.size());
     }      
}

Select an option to see the answer and solution.

Which of this interface must contain a unique element?

Select an option to see the answer and solution.

What is the difference between length() and size() of ArrayList?

Select an option to see the answer and solution.

If the size of the array used to implement a circular queue is MAX_SIZE. How rear moves to traverse inorder to insert an element in the queue?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.util.*;
class Collection_iterators 
{
    public static void main(String args[]) 
    {
        LinkedList list = new LinkedList();
        list.add(new Integer(2));
        list.add(new Integer(8));
        list.add(new Integer(5));
        list.add(new Integer(1));
        Iterator i = list.iterator();
        Collections.reverse(list);
  Collections.shuffle(list);
        i.next();
        i.remove();
        while(i.hasNext())
      System.out.print(i.next() + " ");
    }
}

Select an option to see the answer and solution.

PriorityQueue is thread safe.

Select an option to see the answer and solution.

Which of these method is used to make a bit zero specified by the index?

Select an option to see the answer and solution.

Which of these is a method of class Date which is used to search whether object contains a date before the specified date?

Select an option to see the answer and solution.

Which of these is a class which uses String as a key to store the value in object?

Select an option to see the answer and solution.

When two threads access the same ArrayList object what is the outcome of the program?

Select an option to see the answer and solution.

What will be the output of the following Java 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());
    }
}

Select an option to see the answer and solution.

Which data structure is used in Breadth First Traversal of a graph?

Select an option to see the answer and solution.

Which of these classes is not part of Java's collection framework?

Select an option to see the answer and solution.