About Question enthuware.ocpjp.v21.2.3096 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
giginar
Posts: 23
Joined: Fri Feb 07, 2025 5:36 pm
Contact:

About Question enthuware.ocpjp.v21.2.3096 :

Post 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.

admin
Site Admin
Posts: 10449
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 135 guests