Hello,
The following are the highlights of the errors I've found in chapter 1 of the book "OCA: Oracle Certified Associate
Java SE 8 Programmer I Study Guide". I preferred offering up too much errata, so you might find a few of these to be picking at straws. That having been said, there are many additional notes I have taken but that do not qualify as errata. Instead they are additional tips I hope to pass on to a few of my friends who are more new to Java than me. If you wish, I could share that with you too if you think it might benefit the next edition of your book, but it probably doesn't belong in this errata
thread.
So without further ado:
Page 8, exception at the bottom of the page
It reads:
But it should read:
(Technically Zoo can be found just about anywhere in this output, but this early in the book, explaining that might be heavy).
So the key differences are that I would recommend striking out "mainmethod." and changing the line number from 7 to 4.
Note that this change is the same as the first item listed here, but on a different page:
http://www.pmsas.pr.gov.br/wp-content/?id=coderanch-1z0-809&exam=t/656273/ocajp/certification/minor-typos-chapter-Java-OCA
Page 10, 2nd paragraph, 3rd line
"If it begins with java or javax, this means it came with the JDK."
This is not always true for javax. I could create the following for example:
This compiles and runs fine.
Here's a link that demonstrates plenty of regularly used code that is not, or at least did not start out as, included in Java, that start with javax:
http://mvnrepository.com/search?q=javax
My understanding of why most of these start with javax is because they are implementing a JSR before it is officially bundled with the JVM. Sometimes that can take years, but one can get early-access by incorporating a jar that has the code with the right package names and implementation.
Page 10, 2nd paragraph, 4th line
"From example" should be "For example".
Page 12, top half of the page
For the 6th import from the top, the comment reads:
But just to add clarity (as mentioned at the end of page 10), this should be:
Your solution may be different, I am just trying to find a way to not have an unqualified blanket statement in this comment.
Page 12, at the bottom of the page
It reads:
But it could use some clarification, like:
or an even better solution might be to simply re-include the original code, and do this:
Page 18, in the section Instance Initializer Blocks
It reads:
"Anywhere you see braces is a code block".
This would include the braces in "class A {}" according to this phrasing, right?
Further down, it reads:
"Other times, code blocks appear outside a method. These are called instance initializers."
By this sentence, there is no room for the braces of "class A {}" being considered a code block, because class definition braces are certainly not instance initializers.
You can even go a bit further and say that you can have other blocks outside of a method, like static initializers, array initializers, etc.
So perhaps I would avoid saying that all blocks outside of a method are instance initializers.
And maybe clarify "code blocks" to say whether or not you even include class definition blocks, because you don't cover that in any of your examples.
Page 24, middle of the page
It reads:
"For example, the following statements assign these references to new objects:"
[...]
"Similarly, the greeting reference points to a new
String object, "How are you?"."
Technically, there's some optimizations on Strings that are often made such that using the same literal twice will result in the same object on the heap.
Here's an example:
So a bit of clarification language can leave the door open to this. For example, throwing in an "Assuming the string "How are you?" is never used anywhere else in the program, ...".
In my own copy of the book, I wrote next to the source listing for the string assignment: "Might reuse an existing string if the same literal is used elsewhere".
Page 30, top of the page
It reads:
But it should say:
page 30, bottom of the page
It reads:
"Class variables are shared across multiple objects."
Since this is pretty much the definition in the book for class variables, I wouldn't phrase it in quite that way. You can have zero instances and still have a class variable. The variable is more attached to a class metaobject that is accessible by objects of that class type (amongst others).
Page 31, end of second paragraph
It reads:
"and so wants the simplest type it can give the value"
The words are reversed. This should be:
"and so wants the simplest value it can give the type"
Page 31, table 1.2
I would prefer if, for float, it said the initialization value was 0.0f instead of 0.0, because the latter wouldn't compile in the case of an assignment.
Page 34, table 1.4
Perhaps not an errata, but more of a note: if this table were titled "Elements of a compilation unit", then it wouldn't be valid to say that a class declaration is required. However, it is titled "Elements of a class", and I suppose no declaration, no class. But it will compile. Just want to make sure that's clear.
Page 35, near the bottom just before the last code listing of the page
It reads:
"For example, these two classes must be in a file named Meerkat.java"
I would just add a slight clarification:
"For example, these two classes, if put together in a single file, must be put in a file named Meerkat.java".