• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 10 pages
Exam (elaborations)

Cs121 Final Questions And Correct Answers

Document preview thumbnail
Preview 2 out of 10 pages

Cs121 Final Questions And Correct Answers

Content preview

CS121 FINAL QUESTIONS AND CORRECT ANSWERS


A nonlinear collection in which there is essentially no inherent organization to the
elements in the collect - Answers - Set

The difference between a set and map is that a set stores the key and the data _____
while a map separates the key from the data and only stores the key and a reference to
the data - Answers - Together

Which data structure does not keep its elements in any type of order - Answers - set

What happens when we try to add an element to a set in which the element is already
present - Answers - it is not added

Which data structures can be used to implement a set from Java API - Answers -
Hashtable and balanced binary tree

To use a treeset, your objects must belong to a class that implements the ____
interface - Answers - Comparable

Which java code is not correct - Answers - hashset<String> cats = new
treeset<String>();

In our lab 13, a set was implemented by using a linked node (list), then what complexity
would testing for containment have? - Answers - O(n)

Do not use PC. What is the correct answer on the console window?



Set<String> myset1 = new treeset<String>();

Myset1.add("X");

Myset1.add("Y");

Myset1.add("X");

Myset1.add("Z");

Set<String> myset2 = new treeset<String>();

Myset2.add("Y");

, Myset2.add("Z");

Myset2.add("W");

Myset2.add("Y");

Set<String> set3 = new treeset<String>(myset1);

Set3.retainall(myset2);

System.out.println(set3); - Answers - [Y, Z]

Do not use PC. What is the correct answer on the console window?

Set<String> myset1 = new treeset<String>();

Myset1.add("X");

Myset1.add("Y");

Myset1.add("X");

Myset1.add("Z");

Set<String> myset2 = new treeset<String>();

Myset2.add("Y");

Myset2.add("Z");

Myset2.add("W");

Myset2.add("Y");

Set<String> set3 = new treeset<String>(myset1);

Set3.removeall(myset2);

System.out.println(set3); - Answers - [X]

Do not use PC. What is the correct answer on the console window?

Set<String> myset1 = new hashset<String>();

Myset1.add("X");

Document information

Uploaded on
October 4, 2026
Number of pages
10
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$14.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Greaterheights
4.0
(224)
Sold
1178
Followers
882
Items
20955
Last sold
17 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions