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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

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.


Why might you use List<? extends Object> instead of List<?>?

  1. To clarify that objects in the List extend Object

  2. To allow addition of any object type to the List

  3. There is no practical use; they mean the same thing

  4. To differentiate from raw types in method signatures

The correct answer is: There is no practical use; they mean the same thing

List<?> and List<? extends Object> essentially have the same meaning, as both are wildcard types that can store any type of objects. Therefore, there is no practical difference in using one over the other. Option A is incorrect because the keyword "extends" is not necessary when using the wildcard "?". Option B is incorrect as both options allow for the addition of any object type to the list. Option D is incorrect because the usage of wildcard types is not related to differentiating from raw types in method signatures.