enthuware.ocpjp.v11.2.3516

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

Moderator: admin

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: 10036
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!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: marpiva and 34 guests