Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 40
2
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Chapter 14 exercise 2 the line

calls the method

of java.util.List. It does not call

to remove the element 2 as one might expect, but instead removes the element at index 2, which is 6.

This actually doesn't matter to correctly answer the question, but on page 838 the authors do claim that the number 2 is removed which is wrong.
Alternatively you might say the answer is right and that the line should have been:

 
Henno Vermeulen
Ranch Hand
Posts: 40
2
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Exercise 8 of chapter 14 the line

gives the caller of the getHighScores() method a read-only view of the private ArrayList that is intended to be guarded by the lock.

However, the returned list is backed by the original ArrayList and the caller will read the returned list without having the read lock. This means that this code is actually not thread safe: the caller may read from the list while another thread is running the addScore() method; for example in the middle of sorting it. This means that getting an element at a certain index may give unpredictable results.

This actually doesn't matter for answering the question correctly, but it is very suggestive. It could give the reader a false sense that Collections.unmodifiableList returns a thread-safe collection.

I think the intent of the code was to return an unmodifiable snapshot of the highscores list. One way to implement this is to replace the line with
 
Greenhorn
Posts: 1
Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Chapter 8 Self Test Question 2 (p 466) :

The value "en_CA" is passed to the Locale constructor as a language code.
Even though it is an invalid language code, the Locale constructor still accepts it.

If you run the following :

the output is :
Language: en_ca
Country:

So the correct answers would be A or A and E depending on the system being case sensitive or not...

In order to match the answers A, C, D and E, the code of question 2 should be :
 
Ranch Hand
Posts: 39
5
Spring Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 927 - Example from Using Savepoints with JDBC...

Savepoint sp1 is not available in the scope in which it is rolled back.


Should be
 
James Pittendreigh
Ranch Hand
Posts: 39
5
Spring Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also I posted this a while ago, don't know if it's valid or worth going in the Errata... what do you think Roel?
https://coderanch.com/t/649127/java-programmer-SCJP/certification/Thread-Safe-Singleton-section-KS

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 8, self test question 3 - Kindle edition

This issue is already in the errata, which correctly states that a substitution for $7 occurs.
Another approach is to use apostrophes instead of quotation marks.
This will prevent the substitution.
 
R Svendsen
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OCP Mock Exam 1 Question 20 - Bango, Bongo, Bingo

Correct and incorrect answers are inverted.
B,C,D,F,G are listed as correct.
A, E are listed as incorrect.
 
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 14, page 810.

Halfway the page in the Executor implementation example is printed: I found no executor() method in the API documentation. I suppose this must be
 
Rijk van de Scheur
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 15, page 874: getTime method

The code example for the public java.sql.Time getTime(String columnLabel) currently is: and has to be:
 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found various small errors and will post them as I fall over them again while reviewing the book for exam preparation. If the errors are already reported, please feel free to delete my posts.

page 929 (CERTIFICATION SUMMARY JDBC)

"...added to the Connection object (the Connection.createConnection(int,int) method...." should be Connection.createStatement(int,int)
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chapter 12, self-test 8
code line numbers seem to be irrelevant here, no response uses them
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Henno Vermeulen wrote:In Chapter 14 exercise 2 the line

calls the method

of java.util.List. It does not call

to remove the element 2 as one might expect, but instead removes the element at index 2, which is 6.


Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Henno Vermeulen wrote:In Exercise 8 of chapter 14 the line

gives the caller of the getHighScores() method a read-only view of the private ArrayList that is intended to be guarded by the lock.


Added to the errata overview.
 
Greenhorn
Posts: 4
C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Two-Minute Drill at the end of Chapter 6 (page 361) contains the following statement:

"The default block can be located anywhere in the switch block, so if no preceding case matches, the default block will be entered, ..."

I suggest that the word "preceding" is not quite correct; if no other case matches, the default block will be entered.

Ref: http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html "If no case matches but there is a default label, then all statements after the matching default label in the switch block, if any, are executed in sequence." Note that it says "no case", not "no preceding case".

In years of coding (mostly C/C++), I don't think I've ever seen a default block anywhere but at the end of the switch statement; so the word "preceding" will almost always be correct. But I was worried when I saw this in the book, because I thought it was just the kind of thing the OCA exam might try to use to trip up a hapless candidate.

Don
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nicolas Lepage,

First of all, a warm welcome to CodeRanch!

Nicolas Lepage wrote:Chapter 8 Self Test Question 2 (p 466) :

The value "en_CA" is passed to the Locale constructor as a language code.


Added to the errata overview.

Kind regards,
Roel
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Pittendreigh wrote:Page 927 - Example from Using Savepoints with JDBC...

Savepoint sp1 is not available in the scope in which it is rolled back.


Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

R Svendsen wrote:Chapter 8, self test question 3 - Kindle edition

Another approach is to use apostrophes instead of quotation marks.
This will prevent the substitution.


Thanks for the suggestion! But this will only work on a Unix/Linux machine. If you use single quotes (apostrophes), these single quotes are part of the arguments and the program won't work anymore

Kind regards,
Roel
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

R Svendsen wrote:OCP Mock Exam 1 Question 20 - Bango, Bongo, Bingo

Correct and incorrect answers are inverted.


Already added to the errata overview.
 
Henno Vermeulen
Ranch Hand
Posts: 40
2
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OCA Mock Exam Question 41.
According to the answers, the statement "Encapsulation makes it easier to reuse classes" should be true.
I think this is not immediately obvious and is debatable, so I would lean to not true.

I'm not 100% sure if the answer is really wrong, perhaps this is more of a gray area. See also my question about this on the forum.
 
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on chapter 3, page 175, in exam watch notes

As is:
int j, k=m+3, l, m=1; // illegal: m is not initialized before k uses it

To be:
int j, k=m+3, l, m=1; // illegal: m is not declared and initialized before k uses it
 
Henno Vermeulen
Ranch Hand
Posts: 40
2
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The diagram on page 494 claims that the (java.nio.file.)Files class uses the Paths class. This is not correct. It uses the Path interface!
 
Henno Vermeulen
Ranch Hand
Posts: 40
2
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 504 they say about this:



that it "tries to resolve a directory within the context of a file. Since that doesn't make any sense, Java just tries its best and gives you nonsense.".
However as mentioned in the book itself, an instance of Path does not know whether a file or directory referenced by it actually exists. In fact it contains no information on whether it is a file or directory.
AFAIK on Unix/Linux and Windows it is allowed to create a directory whose name contains a dot and a file that does not have an extension.

So Java actually does not give nonsense but does the only right thing to do here. For all it knows the Path referred to by "Model.pdf" may be a directory and the Path referred to by "dir" may be a file!

 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 10 page 552
Currently:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the class Show would be able to use the singleton.
Correct:
If getInstance() weren't public, we would still have a singleton. However, it wouldn't be as useful because only static methods of the package would be able to use the singleton.
 
J Deckarm
Ranch Hand
Posts: 41
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chapter 8, page 458
We can call getObject() to get a non-String value:
Locale locale = new Locale(args[0], "CA");
=> args[0] doesn't seem to make much sense here, from the example context it should be likely "en" instead
 
You've gotta fight it! Don't give in! Read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic