What allows List<? super Apple> to safely add an Apple object?

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.

Generics in Java use the term "super" to represent a lower bound. In this context, "? super Apple" means that the list can accept any type that is a superclass of Apple. So, option C is correct because it allows for any type as long as it is a base type of Apple. Option A is incorrect because it specifies a lower bound, not an upper bound. Option B is incorrect because it guarantees only that the list contains Apple objects, not necessarily that only Apple objects can be added. Option D is incorrect because it does not automatically cast added objects to Apple.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy