About Question enthuware.ocpjp.v8.2.1878 :

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

Moderator: admin

Post Reply
pavelkubal
Posts: 1
Joined: Sun Oct 11, 2015 3:07 pm
Contact:

About Question enthuware.ocpjp.v8.2.1878 :

Post 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.
Attachments
Screen Shot 2018-01-01 at 11.46.42.png
Screen Shot 2018-01-01 at 11.46.42.png (177.97 KiB) Viewed 5169 times

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

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

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

henrid
Posts: 31
Joined: Sun Oct 13, 2013 1:20 pm
Contact:

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

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

bvrulez
Posts: 33
Joined: Sat Feb 15, 2020 12:44 am
Contact:

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

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

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

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

Post by admin »

Should be easy to check :)
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 59 guests