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