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

6/9

Page

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

Set has contains(Object o) method.

Select an option to see the answer and solution.

Which of these package is used for remote method invocation?

Select an option to see the answer and solution.

What is the relation between hashset and hashmap?

Select an option to see the answer and solution.

Which of these return type of hasNext() method of an iterator?

Select an option to see the answer and solution.

Which of these is an incorrect form of using method max() to obtain a maximum element?

Select an option to see the answer and solution.

Which of these methods is used to obtain an iterator to the start of collection?

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[]) 
    { 
        TreeSet t = new TreeSet();
        t.add("3");
        t.add("9");
        t.add("1");
        t.add("4");
        t.add("8"); 
        System.out.println(t);
    }
}

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.fill(array, 1, 4, 8);
        for (int i = 0; i < 5 ; i++)
            System.out.print(array[i]);
    }
}

Select an option to see the answer and solution.

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());
    }
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which of these is true about unmodifiableCollection() method?

Select an option to see the answer and solution.

What will be the output of the following Java code?
import java.lang.reflect.*;
class Additional_packages 
{	 
     public static void main(String args[]) 
     {
   try 
         {
       Class c = Class.forName("java.awt.Dimension");
 Constructor constructors[] = c.getConstructors();
 for (int i = 0; i < constructors.length; i++)
     System.out.println(constructors[i]);
   }
   catch (Exception e)
         {
         System.out.print("Exception");
         }
    }
}

Select an option to see the answer and solution.

Which of these method is used add an element and corresponding key to a map?

Select an option to see the answer and solution.

How to remove duplicates from List?

Select an option to see the answer and solution.

Which of these iterators can be used only with List?

Select an option to see the answer and solution.

Is hashmap an ordered collection.

Select an option to see the answer and solution.

How is Arrays.asList() different than the standard way of initialising List?

Select an option to see the answer and solution.

What is difference between dequeue() and peek() function of java?

Select an option to see the answer and solution.

What is Remote method invocation (RMI)?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.