Java Set MCQs with answers Page - 7

You will find multiple-choice questions (MCQs) related to #Java Set here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 828.43K Points
Coach

Q. Which interface is extended by NavigableSet?

  • (A) Queue
  • (B) SortedSet
  • (C) Map
  • (D) List

A

Admin • 828.43K Points
Coach

Q. Which Set implementation provides methods like pollFirst() and pollLast()?

  • (A) TreeSet
  • (B) HashSet
  • (C) LinkedHashSet
  • (D) EnumSet

A

Admin • 828.43K Points
Coach

Q. What is returned by TreeSet's `first()` method?

  • (A) Null
  • (B) The highest element
  • (C) The smallest element
  • (D) Random element

A

Admin • 828.43K Points
Coach

Q. Which Set method checks if a particular object is in the Set?

  • (A) has()
  • (B) inSet()
  • (C) contains()
  • (D) includes()

A

Admin • 828.43K Points
Coach

Q. Which class provides a concurrent sorted set implementation?

  • (A) TreeSet
  • (B) ConcurrentSkipListSet
  • (C) CopyOnWriteArraySet
  • (D) LinkedHashSet

A

Admin • 828.43K Points
Coach

Q. Which method is used to get the last element in a TreeSet?

  • (A) last()
  • (B) end()
  • (C) top()
  • (D) getLast()

A

Admin • 828.43K Points
Coach

Q. Which collection class can be used to avoid duplicates and maintain sorted order?

  • (A) HashMap
  • (B) TreeSet
  • (C) ArrayList
  • (D) HashSet

A

Admin • 828.43K Points
Coach

Q. Which of these Set types allows only enum constants?

  • (A) EnumSet
  • (B) TreeSet
  • (C) LinkedHashSet
  • (D) SortedSet

A

Admin • 828.43K Points
Coach

Q. Which of these is a legacy class that can function as a Set?

  • (A) Vector
  • (B) Hashtable
  • (C) Stack
  • (D) None of the above

A

Admin • 828.43K Points
Coach

Q. Which method removes a specific element from a Set?

  • (A) delete()
  • (B) erase()
  • (C) remove()
  • (D) cut()
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More