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.


Why is the use of raw types discouraged in Java generics?

  1. They cause the application to use more memory

  2. They can lead to runtime exceptions

  3. They provide type safety

  4. They cannot be used with collections

The correct answer is: They can lead to runtime exceptions

Raw types are not recommended in Java generics because they can lead to unexpected runtime exceptions. When using raw types, the code has no way to ensure type safety, so the compiler cannot catch potential errors at compile time. Additionally, raw types cannot be used with collections, which can cause compatibility issues when attempting to use them with other generic types. While it is true that they do not provide type safety, they are not recommended for this reason rather than for the reason of using more memory.