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

Question: 1 / 510

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

Objects of any type

Only objects of the specified wildcard type

Only null

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.

Get further explanation with Examzify DeepDiveBeta

Only objects of the base class of the wildcard type

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy