Java Collections Quiz

Java Collections Quiz

University

11 Qs

quiz-placeholder

Similar activities

Java Programming Quiz

Java Programming Quiz

University

13 Qs

Midterm 2 Quiz

Midterm 2 Quiz

University

16 Qs

RANDOM QUIZ

RANDOM QUIZ

University

10 Qs

ANTENNA ARRAYS

ANTENNA ARRAYS

University

10 Qs

Bài tập biến mảng

Bài tập biến mảng

1st Grade - University

10 Qs

Array - C++ Programming

Array - C++ Programming

University

9 Qs

Real Estate Principles Chaper 8 and 9

Real Estate Principles Chaper 8 and 9

University

12 Qs

GPS P1

GPS P1

University

10 Qs

Java Collections Quiz

Java Collections Quiz

Assessment

Quiz

Other

University

Hard

Created by

Niveditha N

Used 1+ times

FREE Resource

11 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which Java collection class is most suitable to represent a shopping cart where items can be accessed by index and duplicates are allowed?

HashSet

HashMap

ArrayList

TreeSet

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a school attendance system where each student should be marked present only once, which collection would you use?

ArrayList

HashSet

TreeMap

Stack

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You are building a dictionary application where each word maps to its meaning. Which collection is best suited?

LinkedList

Stack

HashMap

TreeSet

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which collection would you use to store a list of students in the order of registration, without allowing duplicates?

TreeMap

LinkedHashSet

PriorityQueue

Hashtable

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following?

List list = new ArrayList<>();

list.add("A"); list.add("B"); list.add("A");

Set set = new HashSet<>(list);

System.out.println(set.size());

2

3

Compilation Error

Runtime Exception

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of this code? List list = new ArrayList<>(); list.add("A"); list.add("B"); list.add(1, "C"); System.out.println(list);

[A, B, C]

[A, C, B]

[C, A, B]

Compilation Error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider this code: List list = Arrays.asList(1, 2, 3, 4, 5); list.set(2, 10); System.out.println(list);

[1, 2, 10, 4, 5]

[1, 10, 3, 4, 5]

Compilation Error

Runtime Exception

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?