Page 1 of 1

About Question enthuware.ocpjp.v21.2.3096 :

Posted: Sun Dec 21, 2025 3:48 pm
by giginar
Hi,

When we see a code with generics in super class and the sub class is overriding it, should we directly eleminate options like 1 and 2?

Because overriding class' method also have to be generic? Is this the reason option 1 and 2 eleminated? otherwise, what is the difference between option 1 and 3? Thanks.

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

Posted: Tue Dec 23, 2025 2:48 am
by admin
Yes, if you have a variable for a parameterized generic type such as List<T> (the type variable is T here) then you can safely eliminate anything that doesn't use a type variable such as List<Set> because T may be typed to any type other than Set at runtime and in that case List<Set> won't be compatible with List<T>.

Please to through the type hierarchy given in the explanation also.