Page 1 of 1
About Question enthuware.ocpjp.v8.2.1878 :
Posted: Mon Jan 01, 2018 5:50 am
by pavelkubal
Hi I think, that this question has wrong answer.
the first one is marked as correct anwer, but it doesn't compile
public static double compute(double base, Function<Integer, Integer > func){
return func.apply((int)base);
}
However the third one does compile and is marked as invalid.
Re: About Question enthuware.ocpjp.v8.2.1878 :
Posted: Mon Jan 01, 2018 7:12 am
by admin
Are you sure you typed the code as given in the question while trying it out? I tried it just now and option 1 compiles fine.
-Paul.
Re: About Question enthuware.ocpjp.v8.2.1878 :
Posted: Thu Sep 12, 2019 5:37 pm
by henrid
I already knew that widening and boxing do not go together. But did I just learn today that widening and UNboxing is allowed? This part is not testing Java 8, but okay, nice to know.
Re: About Question enthuware.ocpjp.v8.2.1878 :
Posted: Thu Feb 20, 2020 10:26 am
by bvrulez
I wonder if the cast from double to int might pose a problem since the max value of a double is 1.7*10^308 and that of an int is just 2^31-1, and also regarding their minimums.
Re: About Question enthuware.ocpjp.v8.2.1878 :
Posted: Thu Feb 20, 2020 10:35 am
by admin
Should be easy to check
