Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What type of collection does entrySet() return?

  1. List

  2. Set

  3. Queue

  4. Map

The correct answer is: Set

The entrySet() method returns a Set because it is designed to return all pairs (key-value) contained in a Map as a Set. Even though a Set is similar to a List in that both can store multiple values, a Set is more suitable since it does not allow duplicates. A Queue on the other hand is used for specific data manipulation such as insertion and deletion at different ends, and thus does not relate to the entrySet() method. Finally, although a Map also stores key-value pairs, it does not return the entire entries as a Set and therefore is not the correct type of collection for the entrySet() method.