Multiple choice technology programming languages

public void addAnimal(List super Dog> animals) { animals.add(new Dog()); } it's NOT legal to add when we use Wildcard character >.(True/ False)

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The wildcard ? super Dog represents an unknown type that is a supertype of Dog. Because the type is guaranteed to be a supertype of Dog, it is completely legal to add a Dog (or its subclasses) to this list. Thus, the statement claiming it is NOT legal is false.