What types of objects can List<?> accept via its add method?

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.

A List<?> can accept objects of any type via its add method. This means that the specific type of element being added to the list does not need to be specified. Therefore, options A and B are incorrect.

Option C, which states that the list can only accept null, is also incorrect. While it is true that null is a valid object and can be added to a list, it is not the only type of object that can be added using the add method.

Option D is incorrect because a List<?> can accept objects of the wildcard type as well as any of its subclasses. So it is not limited to accepting only objects of the base class of the wildcard type.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy