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

Disable ads (and more) with a premium pass for a one time $4.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.

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.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy