Mastering Java: The Ultimate Quiz for 'Thinking in Java'

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

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What restriction does using <? super T> in a generic class or method impose?

  1. The class or method cannot accept arguments of type T

  2. Objects of T or its superclasses can be added to a collection

  3. The class or method cannot return objects of general types

  4. Only objects of type Object can be used with the class or method

The correct answer is: Objects of T or its superclasses can be added to a collection

When using a generic class or method with the <? super T> restriction, objects of type T or any of its superclasses can be added to a collection. This means that objects of more specific types cannot be added, but it allows for a wider range of objects to be accepted. Options A, C, and D are incorrect because they imply more limitations on the type of objects that can be used, while option B provides the most accurate description of the restriction imposed by <? super T>.