logo

Crowdly

Browser

Add to Chrome

Which of the following statements are true? Assume that class WildAnimal...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Which of the following statements are true?

Assume that class WildAnimal { } and its subclass class Tiger extends WildAnimal { } exist.

a) Using List<? extends WildAnimal> is a case of contravariance.

b) Assume the following class List and its use (E is a parameter type):

class List<E> { ... // list of elements of type E

              void add (E elem) {

// add elem to list

...

}

}

List<? super Tiger> animalList = new List<>();

It is possible to add an object of type WildAnimal to the list by calling:

animalList.add(new WildAnimal());

c) Using List<? super Tiger> is a case of covariance.

d) List<?> is compatible to a concrete List of any type.

More questions like this

Want instant access to all verified answers on moodle.jku.at?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome