about question enthuware.ocpjp.ii.v11.2.2022

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
entitybean
Posts: 12
Joined: Mon Apr 03, 2017 6:08 am
Contact:

about question enthuware.ocpjp.ii.v11.2.2022

Post by entitybean »

Code: Select all

Identify the correct statements about the following code -  
IntStream is1 = IntStream.of(1, 3, 5);  //1 
OptionalDouble x = is1.filter(i->i%2 == 0).average(); //2 
System.out.println(x); //3  

IntStream is2 = IntStream.of(2, 4, 6); //4 
int y = is2.filter( i->i%2 != 0 ).sum(); //5 
System.out.println(y); //6  
Answer options 2 and 3 mention:

Code: Select all

Compilation failure only at //4
Compilation failure at //2 and //4
Sure that line 4 is asked for in the questions? would doubting line 5 with the filter condition not make more sense?
I think line 2 and 5 are the difficult spots, not line 1 and 4 where "only" a IntStream is defined.

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

Re: about question enthuware.ocpjp.ii.v11.2.2022

Post by admin »

Yes, //5 would make more sense.
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: No registered users and 6 guests