Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Errata: Oracle Certified Professional Java SE 8 Programmer II Study Guide  RSS feed

 
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While studying from the Oracle Certified Professional Java SE 8 Programmer II Study Guide, I took notes on some errata I came across that were not listed yet. Please find them below.

1. page xlix
Question 11: It's not clarified why option D is not correct. Option D will print 1 instead of throwing an exception, making the statement incorrect.

2. page 33
Table 1.2, row number 6, column 1 is saying "Can access local variables of enclosing class". I don't think a class can have local variables. It can have instance and class members, but not local variables. I suppose the sentence means to say "Can access local variables of enclosing method", making the answer in the second and fifth column "N/A" (Member inner classes are not contained within a method and static nested classes can not be defined within a method respectively).

3. page 42
Question 14: In the import statement, there is an extra space between "java.util." and "*"

4. page 103
The last item (Java Stream API) of the overview of OCP exam topics covered in chapter 3 (Generics and Collections) is not covered in this chapter.

5. page 113
The second item in the bullet list of the real world scenario box is saying that it is not possible to "Create an array of that static type". It is not clear to me what is referred to by "that static type". Shouldn't this be "of that generic type"?

6. page 123
Second to last paragraph: "Now on to the methods. Try to figure out why they don't compile". The first method "method1", does compile though.

7. page 136
Table 3.5, description of peek() method: "Returns next element or returns null if empty queue". Note that for Stack (peek is also for stack), an EmptyStackException is thrown if empty stack.

8. page 152
Last sentence of first paragraph: "We will show you how to use the removeIf(), forEach(), merge(), computeIfPresent(), and computeIfAbsent() mehods." The replaceAll() method is also shown in the chapter.

9. page 153
Section just after the bullet list: "In this chapter, we will be using three functional interfaces in our examples. We will use more in the next chapter. Remember from Chapter 2 that Predicate is a functional interface that takes a single parameter of any type and returns a boolean. Another functional interface is Consumer, which takes a single parameter of any type and has a void return type. Finally, Supplier doesn’t take any parameters and returns any type."
In that section, indeed Predicate, Consumer and Supplier is used, but further into the chapter there is also a UnaryOperator (in section "replacing elements") and a Function and BiFunction (in section "Map APIs").

10. page 155
First paragraph of section "Looping through a Collection": "Looping though a Collection...": there is a missing r in though.

11. page 157
Section "computeIfPresent and computeIfAbsent": computeIfPresent() calls the BiFunction if the requested key is found and the associated key not null. "associated key" should be "associated value".

12. page 158
Second paragraph: "For computeIfAbsent(), the functional interface runs only when the key isn’t present or
is null". "or is null" should be "or the value is null".

13. page 159
table 3.11: For merge, the Functional Interface used is "BiFunction (Takes existing value and new value. Returns new value)". I've found "Returns new value" a bit confusing, as it might refer to the new value that is given to the BiFunction. Maybe better would be "Returns result of BiFunction" (can be applied to the other methods (computeIfAbsent and computeIfPresent) too, to be consequent).

14. page 213
The table at the top is a continuation of table 4.10, but doesn't have the header "Table 4.10 Primitive-specific functional interfaces (continued)"

15. page 217
Table 4.11, row 6 "mapping(Function f, Collector dc)": the return type when passed to collect is the generic type R of Collector dc, not Collector.

16. page 247
The sentence just before the section "Working with Durations": "As you can see, you’ll have to pay attention to the type of date and time objects every place you see them.". I think there should be "in" between "objects" and "every place"

17. page 301
Third paragraph: "Java strongly recommends that close() not actually throw Exception". I believe "throw" should be "throws".

18. page 312
The exception under the first paragraph:

Exception in thread "main" java.lang.AssertionError: Invalid season
at TestSeason.test(Test.java:12)
at TestSeason.main(Test.java:18)

"TestSeason" should be "TestSeasons"

19. page 313
In the box "Validating Method Parameters" it is stated to not use assertions to check for valid arguments passed in to a method. On this (http://www.oracle.com/us/technologies/java/assertions-139853.html) Oracle page, it is stated that assertions can be used to enforce constraints on arguments of private methods though.
So I think it would be better to say "...to check for valid arguments passed in to non-private methods".
Also, question 10 in the review questions of chapter 6 is testing this. There is a private method that takes two arguments and one of these arguments is asserted to be greater than 0. In the answers, option E, stating that this is an appropriate use of assertions, is said to be correct.

20. page 315
First paragraph: "Checked exceptions are in the Exception class hierarchy but not the RuntimeException hierarchy. DateTimeParseException, IOException, and SQLException are common checked exceptions."

DateTimeParseException is not a checked Exception. It probably was meant to be "ParseException".

21. page 346
Second paragraph under table 7.5: "ScheduledFuture<V> is identical to the Future<V> class, except that it includes a getDelay() method that returns the delay set when the process was created."
The getDelay() method returns the remaining delay for the next execution (cf. https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Delayed.html).

22. page 363
The table at the top is a continuation of table 7.11, but doesn't have the header "Table 7.11 BlockingDeque waiting methods (continued)"

23. page 374
Requirements for reduce() arguments:

First bullet: "The identity must be defined such that for all elements in the stream u, combiner.apply(identity, u) is equal to u.": u is a result of the accumulator function, it is not an element of the stream. In the java 8 api (https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#reduce-U-java.util.function.BiFunction-java.util.function.BinaryOperator-), it is said like this: "The identity value must be an identity for the combiner function. This means that for all u, combiner(identity, u) is equal to u."

Third bullet: "The combiner operator must also be associative and stateless and compatible with the identity". The combiner needs to be compatible with the accumulator function, not the identity (cf. Java 8 API - https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#reduce-U-java.util.function.BiFunction-java.util.function.BinaryOperator-).

24. page 394:
Question 2:
The answers B, C, E and F do not make sense I think:

B. Callable takes a generic method argument.
C. Callable can throw a checked exception.
E. Runnable returns a generic type.
F. Callable returns a generic type.

As both Callable and Runnable are interfaces, they cannot take arguments, throw exceptions or return something. Their method can though.

25. page 417
Table 8.2 - The java.io stream classes
BufferedWriter and BufferedReader are added to this table, but BufferedInputStream and BufferedOutputStream are missing.

26. page 419
First paragraph: "Not all java.io input stream classes support this operation, and trying to call mark(int) or reset() on a class that does not support these operations will throw an exception at runtime."

mark() and reset() are documented as follows in the JAVA 8 API:

mark() in Reader:
public void mark​(int readAheadLimit) throws IOException
https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html#mark-int-
Indeed an exception (i.e. IOException) will be thrown when it is not supported.

mark() in InputStream
public void mark​(int readlimit)
https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html#mark-int-
The method signature does not declare an IOException to be thrown.

reset() in Reader:
public void reset​() throws IOException
https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html#reset--
Resets the stream. If the stream has been marked, then attempt to reposition it at the mark. If the stream has not been marked, then attempt to reset it in some way appropriate to the particular stream, for example by repositioning it to its starting point. Not all character-input streams support the reset() operation, and some support reset() without supporting mark().

reset() in InputStream:
public void reset​() throws IOException
https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html#reset--
(snippet) If the method markSupported returns false, then: The call to reset may throw an IOException.

Taking this into account, trying to call mark(int) or reset() on a class that does not support these operations might throw an exception at runtime, rather then will.

27. page 431
Section "Understanding object creation"

"When you deserialize an object, the constructor of the serialized class is not called. In fact, Java calls the first no-arg constructor for the first nonserializable parent class, skipping the constructors of any serialized class in between."

I've found this sentence a but ambiguous, as it might be interpreted as the first nonserializable parent class that has a no-arg constructor. It would have been more clear if it was written like this: "Java calls the non-argument constructor of the first nonserializable parent class. If this parent class does not have a non-argument constructor, an InvalidClassException is thrown".

28. page 433
Third paragraph: "Because PrintStream inherits OutputStream and PrintWriter inherits from Writer, ..."
The word "from" is missing between "inherits" and "OutputStream".

29. page 458:
The examples on page 457:

Path path1 = Paths.get("pandas","cuddly.png");
Path path2 = Paths.get("c:","zooinfo","November","employees.txt");
Path path3 = Paths.get("/","home","zoodirectory");

are repeated on page 458 with a URI:
Path path1 = Paths.get(new URI("file://pandas/cuddly.png")); // THROWS EXCEPTION AT RUNTIME
Path path2 = Paths.get(new URI("file:///c:/zoo-info/November/employees.txt"));
Path path3 = Paths.get(new URI("file:///home/zoodirectory"));

Followed by "Notice that these are actually rewrites of our earlier examples, as we can use URI values for both local and network paths."

For path2 in the examples with the URIs, c:/zoo-info should be c:/zooinfo

30. page 460:
Last sentence in the box "Path Object vs. Actual File": "As you shall see in this section, a handful of operations in the Path and Paths classes, such as Path.toRealPath(), do require the file to exist and will throw a checked exception if the file is not available."

Path.toRealPath() is the only method in Path (and Paths) that requires the file to exist and will throw a checked exception if the file is not available, in contrast to "a handful".

31. page 476:
In section "Reading and Writing File Data with newBufferedReader() and newBufferedWriter()":
In the second paragraph: "The first method, Files.newBufferedReader(Path,Charset), reads the file specified at the Path location using a java.io.BufferedReader object. It also requires a Charset value to determine what character encoding to use to read the file."
Files.newBufferedReader has an overloaded version that doesn't take a Charset.

32. page 501:
Question 16: "Assuming /squid/food-schedule.csv exists as a regular non-empty file that a program has access to read, ..."
I believe there should be an extra "to" in between "access" and "to read".

33. page 535:
Second paragraph: "On line 23, rs2 is closed because the same Statement runs another SQL statement."
"On line 23" should be "On line 22"

34. page 549:
Answer to question 14: "Code involving instanceof does not compile when there is no way for it to evaluate true.".
I believe this should be "... to evaluate to true". Furthermore, "null instanceOf SomeClass" will evaluate to false and still compile.

35. page 553:
Answer to question one of review questions chapter 13: "Since you need a List, you can eliminate C, D, and E immediately.". E is a LinkedList, so it cannot be eliminated for the reason that it's not a list.

36. page 557:
Question 11: "As written, the code doesn’t compile because the collector expects to get a String immediately before it in the chain.".
More general, the collector expects to get a CharSequence.

37. page 561:
Chapter 7 question 2: "Runnable and Callable statements both take no method arguments as input, ...".
I don't think "Runnable and Callable statements" makes sense. I would rather say "The methods run() and call() both take no method arguments as input, ..."

38. page 563:
Question 12: "Lines m2 and m3 throw a compiler warning"
I believe compiler warnings are given, generated or issued, but not thrown.
 
Marshal
Posts: 61741
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please confirm who the authors of the book are.
I am surprised that so many errors could have been unnoticed for so long. I think I shall have to ask you for more details; I may not have the book in question.
 
Philippe De Neve
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ritchie, the authors of the book are Selikoff and Boyarsky.
 
Campbell Ritchie
Marshal
Posts: 61741
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you I presume this is where you looked for known errata. I think I shall have to wait for Jeanne Boyarsky to comment herself.
 
Philippe De Neve
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed, that's the page I looked for known errata.
 
author & internet detective
Posts: 38911
684
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a spot check some of these are opinions and not errata.  It's a long list so it'll take me a while to go through it. I do want to go through each one though. Even if it is not an errata, it is definitely still something for us to consider when we update the book. So thank you for taking the time to post this. I'll reply once I've gone through it.
 
Jeanne Boyarsky
author & internet detective
Posts: 38911
684
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for numbering them.  Makes it easier to reply. First quarter of feedback:

1) Not explaining why each answer is incorrect is not an errata. It is something we should do in the next edition though as it would be better. So I added it to our private list of improvements for the OCP 11 edition of this book.

2) Confirmed and added to errata

3) The code compiles with a space. I've made a note of it for our COP 11 edition, but it isn't an errata.

4) It's covered on page 156 which is in chapter 3.

5) Confirmed and added to errata

6) The book is correct. The sentence you quoted says "try to figure out why they don't compile or what they do". So you'd be figuring out what method 1 does.

7) The book is correct. This code prints null.

Additionally, the JavaDoc for ArrayDeque documents "Retrieves, but does not remove, the head of the queue represented by this deque, or returns null if this deque is empty."  Also worth noting, ArrayDeque does not extend the legacy Stack class.

8) True. This won't apply in our next book since they won't be new anyway.

9) They are the most important examples so we wanted to highlight those three, not a list of every functional interface.

10) Agreed. I've added this to our list for the OCP 11 book

 
Jeanne Boyarsky
author & internet detective
Posts: 38911
684
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Second quarter of feedback:

11) That sentence says "in a nutshell". We explain more fully on the following page

12) I made a note to consider rewriting this for OCP 11

13) I think this is a personal preference

14) That's not an errata. It's how the page is formatted. It seems fine to me. (But even if it didn't, it is up to the publisher.) The column headers are on both pages which is the important thing to duplicate.

15) Same reason as #10.

16) Both versions sounds right to me.

17) Again both versions sound right to me

18) Confirmed and added to errata

19) You are correct. I've added this to our list of things to clarify in the OCP 11 version of this book

20) Yes. This is already in the errata. This was a mistake we made due to not knowing it so it is consistently wrong. We put it in the errata under page "various" and wrote "DateTimeException and DateTimeParseException are not checked exceptions. Pretend they are for the purposes of this chapter as the examples misuse it."

 
Jeanne Boyarsky
author & internet detective
Posts: 38911
684
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Third quarter of feedback:

21) Confirmed and added to errata

22) Same comment as #14

23) Agreed. This section makes my head spin so I just put it on the list for OCP 11 rather than trying to rewrite it right now

24) That's an English thing. Both book authors and test authors sometimes use shorthand

25) We wanted to limit this table to one page. It's already really long.

26) I disagree. If the class, provides a do nothing implementation, that is a type of support. The exception is for classes that do not even do that

27) It sounds ok to me. Maybe Java 11 will be the version of the exam where Oracle finally commits to removing this topic!

28) Personal preference. They both sound right to me

29) Confirmed and added to errata

30) Noted to clarify for OCP 11
 
Jeanne Boyarsky
author & internet detective
Posts: 38911
684
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And final batch of feedback. Thank you for all these comments.

31) So both are true . Will revisit next time

32) It sounds fine to me

33) Either could be right because it is a two line statement. (I know why it is 22 from the point of view of the debugger)

34) Good point! Will revisit for OCP 11

35) There's no chapter 13 . I know you mean chapter 3. Will revisit for OCP 11

36) Both ways are correct

37) "The statements involving Runnable and Callable". This is one of those examples were people use English shortcuts to avoid specifying everything. It's shorter to be precise in code than English

38) Also English shortcut
 
Philippe De Neve
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

Glad to help!

It's exciting to hear you're working on an OCP 11 book. Looking forward to it!

I like to make some clarifications on some points.

4) In fact, only the merge method is covered in chapter 3, not the flatMap method. Furthermore, page 171 lists the exam objectives covered in chapter 4. The last bullet on the page is saying "Use of merge() and flatMap() methods of the stream API". In chapter 4, flatMap() is covered, but not merge().

11) Saying that a key has an associated key is incorrect. A key has instead an associated value. The sentence is indeed saying "In a nutshell", but it's not justifying the statement that a key has an associated key.

15)
I'm convinced this is an errata. For all rows, except the sixth one (mapping), the third column shows the return value of the collect method when the specified Collector is passed to it. For the sixth row (mapping), the third column shows the return value of the mapping method itself, not the return value of the collect method when mapping() is passed to it.

To illustrate this better, I have written examples for the first six rows of the table:



 
Jeanne Boyarsky
author & internet detective
Posts: 38911
684
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Philippe De Neve wrote:4) In fact, only the merge method is covered in chapter 3, not the flatMap method. Furthermore, page 171 lists the exam objectives covered in chapter 4. The last bullet on the page is saying "Use of merge() and flatMap() methods of the stream API". In chapter 4, flatMap() is covered, but not merge().


Understood. However, we have to list the full objective in both places to comply with Sybex style rules. It's not an errata if it is intentional!

Philippe De Neve wrote:11) Saying that a key has an associated key is incorrect. A key has instead an associated value. The sentence is indeed saying "In a nutshell", but it's not justifying the statement that a key has an associated key.
Noted. It's still on our private list of stuff to consider

Philippe De Neve wrote:15) I'm convinced this is an errata. For all rows, except the sixth one (mapping), the third column shows the return value of the collect method when the specified Collector is passed to it. For the sixth row (mapping), the third column shows the return value of the mapping method itself, not the return value of the collect method when mapping() is passed to it.


I'm not saying it doesn't use generics. I'm saying that's how we are listing it in the table. Again, not an errata if intentional.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!