Mastering Java 2025 – 400 Free Practice Questions to Pass the 'Thinking in Java' Exam

Question: 1 / 510

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

It specifies the list must accept Apple as a lower bound

It guarantees the list contains only Apple objects

It allows any type as long as it's a base type of Apple

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.

Get further explanation with Examzify DeepDiveBeta

It automatically casts added objects to Apple

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy