NEW
Font size
WorksheetsJava Collection
Total questions: 10
Worksheet time: 7mins
What is Collection in Java?
A group of objects
A group of classes
A group of interfaces
None of the mentioned
Which of these interface is not part of Java’s collection framework?
List
Sorted List
Set
Sorted Map
Which of these interface declares core method that all collections will have?
Collection
EventListner
Comparator
Set
List
Which interface does java.util.Hashtable implement?
Java.util.Map
Java.util.List
Java.util.HashTable
Java.util.Collection
Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
java.util.HashSet
java.util.LinkedHashSet
java.util.List
java.util.ArrayList
List listNames = new ArrayList();
listNames.add("Tom");
listNames.add("Mary");
listNames.add("Peter");
String name2 = (String) listNames.get(1);
System.out.println(name2);
What is the output of the above code
Tom
Mary
Peter
raises Exception
Which of these methods deletes all the elements from invoking collection?
clear();
reset();
delete();
remove();
HashSet __ support Sorting and __ follows iteration order
do, not
not, not
do, do
not, do
What index value is used to locate the last element in the nums ArrayList?
nums.size()-1
nums.length()-1
nums.size()
nums.length
What will print when the following code executes?
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(7);
list.add(8);
list.add(9);
System.out.println(list.remove(0));
7
8
9
0
