Question 1 of 25
Hints left: 3
Q1
Which of these object stores association between keys and values?
Q2
Which of these methods can be used to move to next element in a collection?
Q3
What is the difference between TreeSet and SortedSet?
Q4
How can we remove an object from ArrayList?
Q5
What does Collections.emptySet() return?
Q6
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); } }
-
A
-
B
-
C
-
D
Q7
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()); } }
Q8
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)); System.out.println(obj.capacity()); } }
Q9
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); } }
Q10
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); } }
Q11
Which of this method is used to make all elements of an equal to specified value?
Q12
What will be the output of the following Java code snippet? public class Demo { public static void main(String[] args) { Map sampleMap = new TreeMap(); sampleMap.put(1, null); sampleMap.put(5, null); sampleMap.put(3, null); sampleMap.put(2, null); sampleMap.put(4, null); System.out.println(sampleMap); } }
Q13
Which of these standard collection classes implements a linked list data structure?
Q14
Which of these interface declares core method that all collections will have?
Q15
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()); } }
Q16
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]);; } }
Q17
Which of these classes implements Set interface?
Q18
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); while(i.hasNext()) System.out.print(i.next() + " "); } }
Q19
Which of these methods can be used to search an element in a list?
Q20
Which of this method is used to change an element in a LinkedList Object?
Q21
What will be the output of the following Java program? import java.util.*; class Output { public static void main(String args[]) { HashSet obj = new HashSet(); obj.add("A"); obj.add("B"); obj.add("C"); System.out.println(obj + " " + obj.size()); } }
Q22
Which of these methods deletes all the elements from invoking collection?
Q23
Which of this interface is not a part of Java's collection framework?
Q24
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.ensureCapacity(3); System.out.println(obj.size()); } }
Q25
Do we have get(Object o) method in HashSet.