KEMBAR78
Java Collections 20 Theory Quiz | PDF
0% found this document useful (0 votes)
11 views4 pages

Java Collections 20 Theory Quiz

This document is a study guide for the Java Collections Framework, containing 20 theory quiz questions with answers. It covers various topics such as collections, lists, sets, maps, and their characteristics. The guide is designed to help learners understand key concepts and functionalities of Java collections.

Uploaded by

shabanihamisi491
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Java Collections 20 Theory Quiz

This document is a study guide for the Java Collections Framework, containing 20 theory quiz questions with answers. It covers various topics such as collections, lists, sets, maps, and their characteristics. The guide is designed to help learners understand key concepts and functionalities of Java collections.

Uploaded by

shabanihamisi491
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java Collections Framework Study Guide

20 Theory Quiz Questions with Answers

1. What is a collection in Java?

A. A type of array

B. A group of related variables

C. A group of objects managed as a single unit

2. Which class implements List?

A. HashMap

B. ArrayList

C. HashSet

3. Which collection maintains insertion order?

A. HashSet

B. TreeSet

C. LinkedList

4. Which interface does HashSet implement?

A. List

B. Set

C. Map

5. What is the characteristic of a Set?

A. Allows duplicates

B. Ordered

C. Unordered and unique elements

6. HashSet is backed by:

A. Array

B. Tree

C. Hash Table

7. TreeSet sorts elements using:

A. Index
B. Insertion Order

C. Natural ordering or Comparator

8. Which method adds an element to a list?

A. put()

B. add()

C. insert()

9. What does map.get(key) return?

A. The key

B. The value

C. null always

10. In Stack, the operation pop():

A. Inserts element

B. Views element

C. Removes the top element

11. Which interface allows duplicate elements and maintains insertion order?

A. Set

B. List

C. Map

Answer: B

12. What type of elements does a TreeSet store?

A. Unsorted elements

B. Null elements

C. Sorted elements

Answer: C

13. What is the primary purpose of a Map?

A. To store unique elements

B. To store key-value pairs

C. To sort data

Answer: B

14. Which of these is a legacy class that was reengineered to implement the List interface?
A. Vector

B. HashMap

C. TreeSet

Answer: A

15. What does the method `contains(Object o)` do in a collection?

A. Adds the object

B. Removes the object

C. Checks if object exists

Answer: C

16. Which collection is best when you need fast access using a key?

A. HashSet

B. HashMap

C. ArrayList

Answer: B

17. Which operation is allowed in Stack?

A. Insert in middle

B. Pop from top

C. Delete from bottom

Answer: B

18. Which method is used to add elements to a Queue?

A. push()

B. add()

C. offer()

Answer: C

19. In a ListIterator, what does the add() method do?

A. Replaces current element

B. Adds after the current position

C. Removes previous element

Answer: B

20. Which of the following does not allow null keys?


A. HashMap

B. TreeMap

C. Hashtable

Answer: C

You might also like