wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Collection

Total questions: 10

Worksheet time: 7mins

Name
Class
Date
1.

What is Collection in Java?

a)

A group of objects

b)

A group of classes

c)

A group of interfaces

d)

None of the mentioned

2.

Which of these interface is not part of Java’s collection framework?

a)

List

b)

Sorted List

c)

Set

d)

Sorted Map

3.

Which of these interface declares core method that all collections will have?

a)

Collection

b)

EventListner

c)

Comparator

d)

Set

e)

List

4.

Which interface does java.util.Hashtable implement?

a)

Java.util.Map

b)

Java.util.List

c)

Java.util.HashTable

d)

Java.util.Collection

5.

Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

a)

java.util.HashSet

b)

java.util.LinkedHashSet

c)

java.util.List

d)

java.util.ArrayList

6.

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

a)

Tom

b)

Mary

c)

Peter

d)

raises Exception

7.

Which of these methods deletes all the elements from invoking collection?

a)

clear();

b)

reset();

c)

delete();

d)

remove();

8.

HashSet __ support Sorting and __ follows iteration order

a)

do, not

b)

not, not

c)

do, do

d)

not, do

9.

What index value is used to locate the last element in the nums ArrayList?

a)

nums.size()-1

b)

nums.length()-1

c)

nums.size()

d)

nums.length

10.

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));

a)

7

b)

8

c)

9

d)

0