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