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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

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.


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.