Java Set MCQs with answers Page - 2

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. What does the `size()` method of a Set return?

  • (A) Total memory used
  • (B) Number of duplicate elements
  • (C) Number of elements in the Set
  • (D) Remaining capacity

A

Admin • 828.43K Points
Coach

Q. Which method checks if a Set is empty?

  • (A) isAvailable()
  • (B) empty()
  • (C) isEmpty()
  • (D) hasElements()

A

Admin • 828.43K Points
Coach

Q. Which Set implementation is best for frequent insertion and removal without order?

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

A

Admin • 828.43K Points
Coach

Q. Which Set is specifically designed for use with enum types?

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

A

Admin • 828.43K Points
Coach

Q. Can TreeSet contain null elements?

  • (A) Yes
  • (B) Only at the end
  • (C) Only one null
  • (D) No

A

Admin • 828.43K Points
Coach

Q. Which of the following is true about Set in Java?

  • (A) Allows duplicates
  • (B) Maintains order of elements
  • (C) Allows multiple nulls
  • (D) Does not allow duplicate elements

A

Admin • 828.43K Points
Coach

Q. Which of the following Set implementations maintains natural ordering?

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

A

Admin • 828.43K Points
Coach

Q. Which interface represents a sorted set in Java?

  • (A) OrderedSet
  • (B) TreeSet
  • (C) SortedSet
  • (D) SortedList

A

Admin • 828.43K Points
Coach

Q. Which method checks if an element is present in the Set?

  • (A) exists()
  • (B) contains()
  • (C) find()
  • (D) has()

A

Admin • 828.43K Points
Coach

Q. Which of the following statements about TreeSet is TRUE?

  • (A) It allows duplicate elements
  • (B) It is synchronized by default
  • (C) It maintains elements in sorted order
  • (D) It allows multiple null values
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