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

Disable ads (and more) with a premium pass for a one time $4.99 payment

Question: 1 / 510

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

They cause the application to use more memory

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.

Get further explanation with Examzify DeepDiveBeta

They provide type safety

They cannot be used with collections

Next

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy