classA {} class B extends A {} class C extends A {} class D extends B {} class E extends B{}
Which three statements are true? a. The type List<A> is assignable to List.// yes
b. The type List<B> is assignable to List<A>. // must be same type
c. The type List<Object> is assignable to List<?>.// No //List<Object> mean this list can hold only List<Object> not List<A> or List<B> or list of any thing List<?>
d. The type List<D> is assignable to List<? extends B>. // No //List<D> cannot hold List<E>
e. The type List<? extends A> is assignable to List<A>.// yes //List<? extends A> any List hold Objects from subclass of A can hold to List<A> which is superclass for them
f. The type List<Object> is assignable to any List reference. // No // its like c g. The type List<? extends B> is assignable to List<? extends A>.// No // List<? extends B> cann't hold List<C>
I think you have got the soul of the generics, and specially this kind of questions.
We should read the questions very carefully. Sometimes we know the concept but due to the reason, we overlook the things, we go wrong. It may happen with anybody.
Firt, sorry for me bad english, it is so bad.
For me it is wrong too.
Besides if the asigment are to rigth -> left, or left -> rigth, never there are 3 answer correct.
For me the question is wrong, in relation of the amount of answer correct.
I hope that someone can undertant me bad english! ;-)