Page 1 of 1

About Question enthuware.ocpjp.v21.2.3087 :

Posted: Mon Oct 13, 2025 9:02 pm
by nnavlani
I know why answer C is right, but then the question I have is why answer A is wrong?

public List<Integer> getList(){
// why is this answer incorrect ???

Re: About Question enthuware.ocpjp.v21.2.3087 :

Posted: Tue Oct 14, 2025 9:03 am
by admin
Because List<Integer> is not a subtype of List<Number>. Go through the rule of covariant returns given in the explanation. It shows two hierarchies of generic types. Read that carefully.