enthuware.ocpjp.v11.2.3516

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Jur_Aj
Posts: 1
Joined: Sat Sep 18, 2021 5:11 am
Contact:

enthuware.ocpjp.v11.2.3516

Post by Jur_Aj »

Hello,

yeasterday I tried this question :

Given: Map<String , List<? extends CharSequence>> stateCitiesMap = new HashMap<String, List<? extends CharSequence>>(); Which of the following options correctly achieves the same declaration using type inference?

Correct answers according to enthuware are :

Map<String , List<? extends CharSequence>> stateCitiesMap1 = new HashMap<>();
and
var stateCitiesMap2 = new HashMap<String, List<? extends CharSequence>>();

Well, seems ok, but the second stateCitiesMap will be HashMap and not Map.

So if you do

HashMap<String , List<? extends CharSequence>> x = stateCitiesMap1; // will not compile
HashMap<String , List<? extends CharSequence>> y = stateCitiesMap2; // will compile

are those two answers really correct ?

Thanks.

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

Re: enthuware.ocpjp.v11.2.3516

Post by admin »

You are right. Updated the problem statement to say "same or compatible declaration".

thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests