Question 1 of 25
Hints left: 3
Q1
Which of these is a class which uses String as a key to store the value in object?
Q2
What is the difference between length() and size() of ArrayList?
Q3
What will be the output of the following Java program? class Output { public static void main(String args[]) { ArrayList obj = new ArrayList(); obj.add("A"); obj.add("D"); obj.ensureCapacity(3); obj.trimToSize(); System.out.println(obj.size()); } }
Q4
Which of these method of HashSet class is used to add elements to its object?
Q5
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.add(0, "B"); System.out.println(obj.size()); } }
Q6
Which of these methods sets every element of a List to a specified object?
Q7
What will be the output of the following Java code? import java.util.*; class properties { public static void main(String args[]) { Properties obj = new Properties(); obj.put("AB", new Integer(3)); obj.put("BC", new Integer(2)); obj.put("CD", new Integer(8)); System.out.print(obj.keySet()); } }
Q8
Which of these classes provide implementation of map interface?
Q9
Map implements collection interface?
Q10
When two threads access the same ArrayList object what is the outcome of the program?
Q11
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(); Collections.reverse(list); Collections.shuffle(list); while(i.hasNext()) System.out.print(i.next() + " "); } }
Q12
Which of the below does not implement Map interface?
Q13
Which of these is a method of class Date which is used to search whether object contains a date before the specified date?
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"); Field fields[] = c.getFields(); for (int i = 0; i < fields.length; i++) System.out.println(fields[i]); } catch (Exception e) { System.out.print("Exception"); } } }
Q15
Which of these methods is used to retrieve elements in BitSet object at specific location?
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); System.out.print(Arrays.binarySearch(array, 4)); } }
Q17
Which of these methods can be used to delete the last element in a LinkedList object?
Q18
Which of these exceptions is thrown by remover() method?
Q19
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.shuffle(list); i.next(); i.remove(); while(i.hasNext()) System.out.print(i.next() + " "); } }
Q20
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(6)); obj.insertElementAt(new Integer(8), 2); System.out.println(obj); } }
-
A
-
B
-
C
-
D
Q21
If the size of the array used to implement a circular queue is MAX_SIZE. How rear moves to traverse inorder to insert an element in the queue?
Q22
Which of these method is used to add an element to the start of a LinkedList object?
Q23
Which of these method is used to make a bit zero specified by the index?
Q24
Which of this interface must contain a unique element?
Q25
PriorityQueue is thread safe.