Multiple choice technology programming languages

What are the benefits of generics?

  1. Generic collections accept only Object types

  2. Type errors are caught at compile time

  3. Generics result in readily understandable code

  4. Generics sometimes require type casting

Reveal answer Fill a bubble to check yourself
B,C,D Correct answer
Explanation

Generics provide compile-time type checking (B), making code more readable and understandable (C). While generics reduce casting, there are scenarios where casting is still needed (D), such as when working with legacy code or raw types. Option A is incorrect because generic collections are designed to accept specific type parameters, not just Object types.