• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Errata for OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide - Appendix A: 7

 
Ranch Hand
Posts: 51
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Appendix question answers, referring to Chapter 7, Question 10, for the following code:

System.out.println(Arrays.asList("duck", "chicken", "flamingo", "pelican").parallelStream().parallel() // q1
.reduce(0, (c1, c2) -> c1.length() + c2.length(),
(s1, s2) -> s1 + s2)); // q3

In the answers, answers say: The problem here is that c1 is a String but c2 is an int, so the code fails to combine on line q2, since calling length() on an int is not allowed, and C is correct.

I think it should be the other way round; c1 is an int (in fact an Integer?) and c2 is a String?

 
Theo van Kraay
Ranch Hand
Posts: 51
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry - another one! In the explanation for Question 22, it says:

"If the submit() method had been used instead of execute(), then C would have been the correct answer, as the output of submit( Runnable) task is a Future <? > object which can only return null on its get() method.

Its true that the output of submit(Runnable) task would be null... but in the actual code in the question being referred to, if changing from execute() to submit() method, it would be a submit(Callable):

IntStream.iterate( 0, i -> i   1). limit( 5). forEach( i -> results.add( service.submit(() -> counter    )) // n1

I apologise again for the pedantry but, in some cases, I am learning these rules for the first time and want to make sure my own understanding is correct as much as anything.

 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#10 is already in the errata. (listed under page 563 where the answer is).

#22 is already in the errata (listed under page 565)

I'd rather have things reported multiple times than not at all though, so thanks for posting.
 
Theo van Kraay
Ranch Hand
Posts: 51
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne. I'll try to be more thorough when checking the errata page before posting. Great book, by the way... I'm enjoying it
 
this is supposed to be a surprise, but it smells like a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic