1. Set has contains(Object o) method.
2. Which of these package is used for remote method invocation?
3. What is the relation between hashset and hashmap?
4. Which of these return type of hasNext() method of an iterator?
5. Which of these is an incorrect form of using method max() to obtain a maximum element?
6. Which of these methods is used to obtain an iterator to the start of collection?
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);
}
}
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]);
}
}
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());
}
}
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());
}
}
10. Which of these methods is used to retrieve the elements in properties object at specific location?
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.