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.
About Question enthuware.ocpjp.v21.2.3096 :
Moderator: admin
-
giginar
- Posts: 23
- Joined: Fri Feb 07, 2025 5:36 pm
- Contact:
-
admin
- Site Admin
- Posts: 10449
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.3096 :
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.
Please to through the type hierarchy given in the explanation also.
Who is online
Users browsing this forum: Bing [Bot] and 135 guests