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

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

Master your knowledge of Java programming with our immersive quiz based on 'Thinking in Java'. Test your skills with detailed questions and receive hints and explanations to enhance your learning. Get ready to ace your Java exam!

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 type of array does not enforce type at runtime due to erasure?

  1. Arrays of primitive types

  2. Arrays of generic types

  3. Multidimensional arrays

  4. Ragged arrays

The correct answer is: Arrays of generic types

Generic types are not allowed in arrays because during the process of type erasure, all generic type information is removed. This means that the array will essentially become an array of objects. This is why arrays of generic types do not enforce type at runtime. On the other hand, arrays of primitive types do enforce type at runtime, as the primitive types cannot be replaced with objects. Multidimensional arrays and ragged arrays also do not affect the runtime type enforcement since they both behave in the same way as regular arrays when it comes to type checking.