nerdexam
Oracle

1Z0-804 · Question #33

Which concept allows generic collections to interoperate with java code that defines collections that use rawtypes?

The correct answer is E. type erasure. The type erasure of its leftmost bound, or type Object if no bound was specified. type parameters type erasure List<String> List Map.Entry<String,Long> Map.Entry <T extends Cloneable & Comparable<T>> Cloneable <T extends Object & Comparable<T>> Object <T> T[] toArray(T[] a)…

Generics and Collections

Question

Which concept allows generic collections to interoperate with java code that defines collections that use rawtypes?

Options

  • Abytecode manipulation
  • Bcasting
  • Cautoboxing
  • Dauto-unboxing
  • Etype erasure

How the community answered

(36 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    14% (5)
  • D
    6% (2)
  • E
    75% (27)

Explanation

The type erasure of its leftmost bound, or type Object if no bound was specified. type parameters type erasure List<String> List Map.Entry<String,Long> Map.Entry <T extends Cloneable & Comparable<T>> Cloneable <T extends Object & Comparable<T>> Object <T> T[] toArray(T[] a) Object[] toArray(Object[] a) The type erasure process can be imagined as a translation from generic Java source code back into regularJava code. In reality the compiler is more efficient and translates directly to Java byte code. But the byte codecreated is equivalent to the non-generic Java code.

Topics

#type erasure#raw types#generics compatibility#backward compatibility

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice