โ† All SCJP Flashcard Decks

Java Generics, Enums, and Autoboxing 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 Generics, Enums, and Autoboxing flashcards as text
  1. What does a wildcard `?` represent in Java generics?

    Answer: Any unknown type

    The wildcard `?` in generics represents an unknown type, used when you don't know or care about the specific type argument.

  2. What is the difference between `List` and `List` in Java?

    Answer: extends is for reading (producer); super is for writing (consumer)

    The PECS principle: `` (Producer Extends) is used for reading elements; `` (Consumer Super) is used for writing elements.

  3. Which enum method returns the name of the enum constant as a String?

    Answer: name()

    The `name()` method returns the exact name of the enum constant as declared in the source code.

  4. Can Java enums have constructors?

    Answer: Yes, but enum constructors are always private

    Enum constructors are always `private` (implicitly or explicitly) because enum constants are created by the JVM, not by external code.

  5. What happens when you compare two Integer wrapper objects with `==` in Java?

    Answer: Compares object references, not values (except for cached range -128 to 127)

    `==` on Integer objects compares references; however, Integer caches values from -128 to 127, so `==` may return true for small values due to the shared cache.

  6. Which of the following is a valid use of a bounded type parameter in Java generics?

    Answer: >

    `>` bounds T to types that implement Comparable, enabling comparison operations within the generic code.

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