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

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


In what way are generics limited in Java?

  1. Generics do not support primitive data types as type parameters

  2. Generics can only be used with collection classes

  3. Generics cannot use wildcard types

  4. Generics can only operate on objects that inherit from a specific superclass

The correct answer is: Generics do not support primitive data types as type parameters

Generics are limited in Java because they do not support primitive data types as type parameters. This means that only objects can be used as type parameters in generics. In contrast, primitive types (such as int, double, boolean) cannot be used, which can be a limitation when dealing with data types that are not objects. Options B, C, and D are incorrect because they do not accurately describe the limitations of generics in Java. Option B is incorrect because generics can be used beyond just collection classes. Option C is incorrect because generics can use wildcard types, which are used to represent unknown types. And finally, option D is also incorrect as there is no restriction on the superclass of the objects used in generics, they just need to be objects.