Intermediate Compilers & Programming Language Theory
Q58 / 100

What is type erasure in generic programming?

Correct! Well done.

Incorrect.

The correct answer is B) Discarding generic type parameters at runtime (Java/Kotlin generics), replacing them with Object and using casts, so no runtime type info is preserved for generics

B

Correct Answer

Discarding generic type parameters at runtime (Java/Kotlin generics), replacing them with Object and using casts, so no runtime type info is preserved for generics

Explanation

Java generics: List<String> and List<Integer> are the same type at runtime (List). Type casts are inserted at call sites. Cannot do instanceof List<String>. C++ templates and C# generics preserve type info (reification).

Progress
58/100