Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Errata for OCA/OCP Java SE 7 Programmer I & II Study Guide (K&B7)  RSS feed

 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Heinz wrote:Chapter 15, page 850.

The figure on this page is a figure from Chapter 9, page 494.

Added to the errata overview (together with the Books_by_Author table you were expecting here).
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thomas Hauck wrote:At the start of "Chapter 14 Concurrency" on Page 785:

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sergey Butenko wrote:Chapter 7, page 399: "What happens if we call the close() multiple times? It depends. For classes that implement AutoCloseable, the implementation is required to be idempotent. Which means you can call close() all day and nothing will happen the second time and beyond. It will not attempt to close the resourse again and it will not blow up. For classes that implement Closeable, there is no such guarantee.

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sergey Butenko wrote:the same incorrect statements are on page 400 (table 7-5 comparing Closable and AutoClosable)

Added both to the errata overview.

Sergey Butenko wrote:on page 405 (two-minute drill, "Autoclosable Resources with a try-with-resources statement", 3rd bullet from top)

Added both to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Morten Banzon wrote:Chapter 9, page 511, last paragraph :

If you forget and use the String " readOnly ," Java will silently ignore the statement and the file will still allow anyone to write to it.

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It took me a little longer as usual, but I was on holiday and had to elminate my backlog first.

But I can now let you all know (with some pride ): the errata overview is up-to-date again, all new reported errata (8) were added.

Thanks for reporting all these errata items!

Happy studying!
 
Raul Saavedra
Ranch Hand
Posts: 38
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 6, the section "Enhanced for loop (for Arrays)" (location 6667 in Kindle).

In the list of illegal examples (// ILLEGAL 'for' declarations), the second illegal example ( for(int x2 : twoDee); ) declares that variable x2 in the for loop, but x2 is already declared in the code before (in fact that was the cause of the illegality for the very first example.) That alone won´t let that second example compile, regardless of the fact that you can´t stuff an array into an int. For clarity´s sake, and to properly illustrate the intended illegality in the second example, the variable declared in that for loop should better not be named x2 then.


 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raul Saavedra wrote:Chapter 6, the section "Enhanced for loop (for Arrays)" (location 6667 in Kindle).

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 1, page 33 - Class Cloo will not be visible to the third class Toon.

An errata item mentioned by Ron Teeple (and discussed) in this thread.

Confirmed & added to the errata overview.
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 470 Chapter 8 Question 7



C is said to be correct in the answers, however, this code will actually put two spaces between the 0 and the 9. So, none of these answers are correct. If one of the " "'s are removed from Line 5, then C will be correct.

Edit: actually, removing the first " " from line 5 will result in a compile error because the + operator is not overloaded for an int and a stringbuilder object, so that is not a valid fix. Removing the second " " works.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37051
507
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 498, test1 should be test1.txt in both examples.

reported here

Confirmed & added to the errata overview.
 
Raul Saavedra
Ranch Hand
Posts: 38
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A very minor thing. In chapter 07, Kindle location 7796, not long before table 7-3, there is an "Exam Watch" box that starts with: "Don't go changing your API signatures on a whim..."
That should be an "on the job!" box, not an Exam Watch. Not a big deal, but when interested in skimming through all the On the job tips or just the Exam-watch tips independently, the proper titles on all of them would be appreciated.
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:On page 498, test1 should be test1.txt in both examples. (added to wiki page)

reported here


Hi Jeanne,
Don't mean to be a pain, but it looks like the addition to the official errata thread is still incorrect. Right now it is:

page 498: Creating, Moving and Deleting Files, 1st and 2nd code blocks
File name should be clearer.
Currently: test1
Should be: "test2

I believe it should be :
Currently: test1
Should be: test1.txt
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Heinz wrote:
Jeanne Boyarsky wrote:On page 498, test1 should be test1.txt in both examples. (added to wiki page)

reported here


Don't mean to be a pain, but it looks like the addition to the official errata thread is still incorrect.

It's true, so you are not a pain at all Updated the errata overview!
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raul Saavedra wrote:A very minor thing. In chapter 07, Kindle location 7796, not long before table 7-3, there is an "Exam Watch" box

Added to the errata overview.
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 518 Chapter 9 I/O

3rd and 4th line from top of page read:
Now what do you think would happen if we changed FileVisitResult.SKIP_
SIBLINGS to FileVisitResult.TERMINATE? The output might be:

I believe, should be:
Now what do you think would happen if we changed FileVisitResult.SKIP_
SUBTREE to FileVisitResult.TERMINATE? The output might be:
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 9 Self Test Question #4 Answer



If line 6 creates a valid Console object and if the user enters fred as a username and 1234 as a
password, what is the result? (Choose all that apply.)
A. username:
password:
B. username: fred
password:
C. username: fred
password: 1234
D. Compilation fails
E. An Exception is thrown at runtime

On Page 538:
D is correct. The readPassword() method returns a char[]. If a char[] were used, answer B would be correct.

I believe the bolded part of the answer is incorrect as the "System.out.println("hello " + u);" output is not included in any of the answers. Consider removing the sysout line from the code snippet or adding the sysout output to answers A, B, and C.
 
Raul Saavedra
Ranch Hand
Posts: 38
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

The modification in ch04 that we discussed in the separate thread ("String Concatenation Operator & Garbage Collection (K&B7 CH5 Q9)") is not yet reflected in the errata page so here I copy/paste your own proposed fix:

Statement in chapter 4 (near Kindle location 5025) is misleading/wrong as it implies the sum is first turned into a String before being concatenated to the other String (which would double the number of objects).

Currently: The previous code can be read as "Add the values of b and c together, and then take the sum and convert it to a String and concatenate it with the String from variable a."

Should be: The previous code can be read as "Add the values of b and c together, and then take the sum and concatenate it with the String from variable a."

Happy 2015 and Kind regards!
Raul
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Heinz wrote:Page 470 Chapter 8 Question 7

Edit: actually, removing the first " " from line 5 will result in a compile error because the + operator is not overloaded for an int and a stringbuilder object, so that is not a valid fix. Removing the second " " works.

Added to the errata overview. Changing the first space (" ") into an empty string ("") will do the job as well
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Heinz wrote:Page 518 Chapter 9 I/O

I believe, should be:
Now what do you think would happen if we changed FileVisitResult.SKIP_
SUBTREE to FileVisitResult.TERMINATE? The output might be:

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Heinz wrote:Chapter 9 Self Test Question #4 Answer

On Page 538:
D is correct. The readPassword() method returns a char[]. If a char[] were used, answer B would be correct.

I believe the bolded part of the answer is incorrect as the "System.out.println("hello " + u);" output is not included in any of the answers. Consider removing the sysout line from the code snippet or adding the sysout output to answers A, B, and C.

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raul Saavedra wrote:The modification in ch04 that we discussed in the separate thread ("String Concatenation Operator & Garbage Collection (K&B7 CH5 Q9)") is not yet reflected in the errata page so here I copy/paste your own proposed fix:

Statement in chapter 4 (near Kindle location 5025) is misleading/wrong as it implies the sum is first turned into a String before being concatenated to the other String (which would double the number of objects).

Although it seemed I forgot about this errata item, it was all this time on my todo list But thanks for this reminder. Added to the errata overview.

You can find this seperate thread here, if you are interested in the complete discussion. Warning: read at your own responsibility (certainly if you new to Java)! It's so far beyond the scope of the OCAJP7 exam, it's even way beyond the scope of the OCPJP7 exam.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 9, page 539: Self Test Answers, Question 8

An errata item mentioned by Chris Heinz (and discussed) in this thread.

Confirmed & added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the errata overview is again completely up-to-date.

My first good deed of this new year! Hopefully followed by many more

Best wishes for 2015!
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 10 Self Test Question #3

3. Given:


Which design pattern or principle is implemented?
A. Coupling
B. DAO
C. Factory
D. IS-A
E. Object composition
F. Singleton

Correct answer on page 571 is declared as: 3. ☑ F is correct. The singleton pattern is identifiable by the static variable for the single instance and the accessor returning it.

The class above does not declare a constructor, therefore it will use the compiler generated default constructor which would be . In this case, a public constructor would allow multiple instances of this class to be instantiated. As stated on page 552, "If the constructor weren't private, we wouldn't have a singleton. Callers would be free to ignore getInstance() and instantiate their own instances. Which would leave us with multiple instances in the program and defeat the purpose entirely."

Consider adding a private constructor to the F class.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Heinz wrote:Chapter 10 Self Test Question #3

Your remark exactly matches my technical review comment For some reason my comment was ignored. But it should definitely be fixed as the private constructor is a must requirement for the singleton design pattern.

question 3
- "F is correct." --> That's Incorrect! To have a singleton pattern you must have a private constructor. Class F doesn't have a private constructor, so this can't be an example of the singleton design pattern


Added to the errata overview.
 
Raul Saavedra
Ranch Hand
Posts: 38
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:
Raul Saavedra wrote:
Although it seemed I forgot about this errata item, it was all this time on my todo list But thanks for this reminder. Added to errata overview.

Thanks for the addition, Roel!

Roel De Nijs wrote:You can find this seperate thread here, if you are interested in the complete discussion. Warning: read at your own responsibility (certainly if you new to Java)! It's so far beyond the scope of the OCAJP7 exam, it's even way beyond the scope of the OCPJP7 exam.

If I may add to that warning, the thread includes wrong/misleading code in some parts because of confusion (mostly of my own) through the evolution of the clarifications, so if checking that thread, make sure you go all the way to the end where the actual issue is finally truly clarified.


 
Raul Saavedra
Ranch Hand
Posts: 38
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another minor submission.

In chapter 10, Kindle location 10685, section "Factory Design Pattern (OCP Objective 3.7)," says:
"To review, Student only interacts with the two abstract classes Factory and BookDao."

But BookDao is actually an interface, not an abstract class.

So it should say:
"To review, Student only interacts with the abstract class Factory and the interface BookDao."
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raul Saavedra wrote:In chapter 10, Kindle location 10685, section "Factory Design Pattern (OCP Objective 3.7)," says:
"To review, Student only interacts with the two abstract classes Factory and BookDao."

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11300
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I discovered an errata item myself too

Chapter 8, Self Test Answers, Question 7 (page 475).

According to the note an exception is thrown when you invoke the insert method using an offset past the current capacity. But the javadoc of StringBuilder disagrees: the exception is thrown if the offset argument is greater than the length of the sequence (or less than 0).

Also illustrated with this code snippet:

Although the capacity is 8, invoking the method with an offset of 4 throws a StringIndexOutOfBoundsException.

Added to the errata overview.
 
Sergey Butenko
Greenhorn
Posts: 12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In class Writer2, page 483



the comment "how many bytes read" is not correct there since read() method reads characters but not bytes, and it returns the number of characters read
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 766 Chapter 13 Threads 4th bullet

When the sleep or wait is over, or an object's lock becomes available, the thread can only reenter the runnable state. It will go directly from waiting to running (well, for all practical purposes anyway).


Should the bolded be, "It will go directly from waiting to runnable"?

From what I've read about threads, it's not possible to go from waiting to running, but I'm also not completely clear on what the, "(well, for all practical purposes anyway)" comment is intended to mean, so maybe it is valid, but I'm not understanding this comment in the correct context...
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 871 Chapter 15

Just a simple typo...

End of the first paragraph:
For the exam, we recommend you focus on the most common SQL data types and the ResultSet methods shown in Table 15-7.


Bolded should be Table 15-8.
 
Chris Heinz
Greenhorn
Posts: 29
1
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 872 Chapter 15 code snippet at top of page



I don't believe this code snippet would run as the column referring to a price is called two different things. One of them(whichever is not the actual column name) would cause a SQLException. See "UnitPrice" in the String query and "Price" in the getFloat method. Edit: Now that I went back and looked at the database that this chapters examples are following, "UnitPrice" is the incorrect one. The correct column name is "Price" as seen on page 849.

Also, "from" in the String query is not capitalized. Should be "FROM".
 
Oli Brown
Greenhorn
Posts: 16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 886, chapter 15: JDBC in Figure 15-6 I think there is a small error with how the invocations are numbered. In the book it is marked 1,2,3 but I think they should be marked 1,3,2 for the invocations to make sense.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!