Generics

6.Which generic wildcard allows both read and write?
  • A. <?>
  • B. <T>
  • C. <? extends T>
  • D. T<?>

<T>

<T>

7.What is the purpose of <? extends T>?
  • A. Accepts any superclass of T
  • B. Accepts T only
  • C. Accepts T and subclasses of T
  • D. Doesn't allow null

Accepts T and subclasses of T

Accepts T and subclasses of T

8. What is the meaning of <? super T> in generics?
  • A. Accepts any subclass of T
  • B. Accepts only T
  • C. Accepts T and any superclass
  • D. Accepts only superclasses

Accepts T and any superclass

Accepts T and any superclass

9. Which of these operations is allowed on a List<? extends Number>?
  • A. list.add(1);
  • B. list.add(null);
  • C. list.add(1.0);
  • D. list.clear();

list.add(null);

list.add(null);