Question 1 of 25
Hints left: 3
Q1
Which of these return type of hasNext() method of an iterator?
Q2
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.sort(list); while(i.hasNext()) System.out.print(i.next() + " "); } }
Q3
Is hashmap an ordered collection.
Q4
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()); } }
Q5
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]); } }
Q6
What are the initial capacity and load factor of HashSet?
Q7
What is the relation between hashset and hashmap?
Q8
Which of these are legacy classes?
Q9
What is difference between dequeue() and peek() function of java?
Q10
Which of these methods is used to retrieve the elements in properties object at specific location?
Q11
Which of these iterators can be used only with List?
Q12
How to remove duplicates from List?
Q13
How is Arrays.asList() different than the standard way of initialising List?
Q14
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"); } } }
Q15
Which of these is an incorrect form of using method max() to obtain a maximum element?
Q16
What is Remote method invocation (RMI)?
Q17
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); System.out.print(obj.get(3)); } }
Q18
Which of these methods is used to obtain an iterator to the start of collection?
Q19
Which of these method of ArrayList class is used to obtain present size of an object?
Q20
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); } }
-
A
-
B
-
C
-
D
Q21
Which of these is true about unmodifiableCollection() method?
Q22
What will be the output of the following Java program? import java.util.*; class Collection_Algos { 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(); while(i.hasNext()) System.out.print(i.next() + " "); } }
Q23
What will be the output of the following Java program? 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
Q24
Which of these class can generate an array which can increase and decrease in size automatically?
Q25
Which of these method is used add an element and corresponding key to a map?