Page 1 of 1

About Question enthuware.ocpjp.v8.2.1864 :

Posted: Tue Nov 17, 2015 1:21 pm
by mihai_d
Answer appears to be wrong for this question:

Code: Select all

Map<String, Integer> map1 = new HashMap<>(); 
map1.put("a", 1); 
map1.put("b", 1); 
map1.merge("b", 1, (i1, i2)->i1+i2); 
map1.merge("c", 3, (i1, i2)->i1+i2); 
System.out.println(map1);
Quiz says it will throw NullPointerException at runtime
However, running the code results in:
{a=1, b=2, c=3}
No hint in the documentation either as to why it would throw NPE in this case.

Re: About Question enthuware.ocpjp.v8.2.1864 :

Posted: Tue Nov 17, 2015 9:22 pm
by admin
You are right but I see that option 1 ({a=1, b=2, c=3}) is indeed marked as correct not option 4 (NPE).

Re: About Question enthuware.ocpjp.v8.2.1864 :

Posted: Thu Dec 17, 2015 4:22 am
by MichaelZett
A really small thing: the font for the 1st answer seems to be smaller than the others,

Re: About Question enthuware.ocpjp.v8.2.1864 :

Posted: Mon Dec 21, 2015 3:46 am
by admin
Fixed.
thank you for your feedback!