โ† All SCJP Flashcard Decks

Java Collections Framework Flashcards

6 cards from real SCJP practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Java Collections Framework flashcards as text
  1. Which Java collection class allows duplicate elements and maintains insertion order?

    Answer: ArrayList

    `ArrayList` is an ordered, index-based list that allows duplicate elements and preserves insertion order.

  2. Which interface does HashMap implement?

    Answer: Map

    `HashMap` implements the `Map` interface, storing key-value pairs where keys must be unique.

  3. What is the time complexity of retrieving an element from a HashMap by key (average case)?

    Answer: O(1)

    HashMap provides O(1) average-case performance for `get()` and `put()` due to hashing.

  4. Which collection maintains elements in a sorted natural order and does not allow duplicates?

    Answer: TreeSet

    `TreeSet` is a sorted Set implementation that stores unique elements in their natural order or by a Comparator.

  5. What happens when you add a duplicate key to a HashMap?

    Answer: The old value is replaced by the new value

    When a duplicate key is inserted into a HashMap, the existing value associated with that key is overwritten.

  6. Which of the following is NOT part of the Java Collections Framework hierarchy?

    Answer: Array

    Arrays are native Java constructs and are not part of the Collections Framework; they do not implement Collection or Map.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy