Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Chapter 2, question 11 in OCP 8 Programmer II Study Guide (pages 98 and 551)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the answer to above review question, the solutions say A, D, F are correct. Why is D correct? It has a lambda expression as in



which isn't valid Java 8, as it tries to declare e both as a parameter and a local variable otherwise in the same lambda. Thanks for any help.

Apologies if this has already been discussed. I wasn't able to find this issue here or in the errata.

I see this in both the online test bank and the Kindle book (ISBN: 978-1-119-06790-0).
 
author & internet detective
Posts: 40239
819
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Benjamin,
Welcome to CodeRanch!

That's odd. The printed book says A and F are correct. (D is clearly wrong). Can you look at the answer text. Mine has this as the second stence "C, D and E are incorrect because the variable e is already in use from the lambda and cannot be redefined."

Granted that's not all that's wrong with it, but it is enough to rule out the answer choice.
 
Benjamin Fischer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for confirming, Jeanne! It seems I'm looking at an outdated version then. The online test and my Kindle book say


A, D, F. B is incorrect because it does not use the return keyword. C and E are incorrect because the variable e is already in use from the lambda and cannot be redefined. Additionally, C is missing the return keyword and E is missing the semicolon. A, D, and F are the only correct lambda expressions that match the functional interface.



I bought the Kindle book this year on January 6, 2019 via www.amazon.co.uk, so it should be a recent version. Anyway, thanks for the help.
 
Jeanne Boyarsky
author & internet detective
Posts: 40239
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Benjamin Fischer wrote:I bought the Kindle book this year on January 6, 2019 via www.amazon.co.uk, so it should be a recent version. Anyway, thanks for the help.


I don't think they update the Kindle book. What's odd is that it was *never* a problem in the print book.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I bought the printed book this July (via bol.com) and it says answers A, D and F are correct, but D is indeed incorrect, because it results in "error: variable e is already defined in method (...)", but this was not in the errata.
Page 552: "A, D, and F are the only correct lambda expressions that match the functional interface."

I have the same ISBN but not the e-book but a printed version. ISBN: 978-1-119-06790-0.
 
Jeanne Boyarsky
author & internet detective
Posts: 40239
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Erik,
Welcome to CodeRanch!

I'm really curious what's going on here. Can you do two things?
1) Take a picture of that part of page 552 and either post it here or email it to me (jeanne at javaranch dot com). I'm curious how else it differs from my copy.
2) Right after the title page of the book (but before the dedication), there is a page with the copyright and a list of everyone who worked on the book. Can you let me know what it says for:
a) copyright (should be 2016)
b) the very last line (should be 10 9 8 7 6 5 4 3 2 1)

I've attached what I see in my copy of the book. As you can see D is clearly incorrect in that. Which matches what we submitted to the publisher in the first place.


page-552.jpg
[Thumbnail for page-552.jpg]
 
Erik Loosman
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne, thank you for your reply. Attached you'll find 2 photo's. One of the copyright-page, because I couldn't find the number you named which should be on the last line. That number is completely different, even in format.
The second photo is answer 11 on page 552.
page-1.jpg
[Thumbnail for page-1.jpg]
page-552.jpg
[Thumbnail for page-552.jpg]
 
Jeanne Boyarsky
author & internet detective
Posts: 40239
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I'm going to ask my publisher what this means. I'm baffled how there's a different copy of the book with different content.
 
Jeanne Boyarsky
author & internet detective
Posts: 40239
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Erik,.
My publisher figured it out! The "10 9 8 7 ..." countdown changed to a different system based on the printer. So it's a legit book and no worries there.

As for the content error: the book has an official errata page and an unofficial one. Scott and I maintain the unofficial one and it is more comprehensive. Somehow the error you describe got introduced to the official errata and a later printing "fixed" it. (The publisher is supposed to ask Scott or I to confirm errata; that got missed here.)

So mystery solved.
 
Marshal
Posts: 70629
288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way the answer is printed isn't clear. It looks as though the correct answer is A D F B at first reading. A little formatting, maybe with more space before the B, would makee that clearer.
 
Jeanne Boyarsky
author & internet detective
Posts: 40239
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:The way the answer is printed isn't clear. It looks as though the correct answer is A D F B at first reading. A little formatting, maybe with more space before the B, would makee that clearer.


Agreed. We are now writing "option X" consistently which avoids this problem
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic