aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Compiling errata for K&B, SCJP 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Compiling errata for K&B, SCJP 6" Watch "Compiling errata for K&B, SCJP 6" New topic
Author

Compiling errata for K&B, SCJP 6

Edward Seager
Greenhorn

Joined: Jan 02, 2010
Posts: 9
Hi,

I think I have found an error on page 583. The example overrides equals() by comparing Strings using == rather than the equals() method. Surly this is wrong?


Eddy Seager
Michael Hilgert
Greenhorn

Joined: Apr 23, 2010
Posts: 17
I think the code is correct, because strings are final and the JVM searches the string pool for the same string, so two equal strings have the same reference.



You're welcome.
SCJP 6, SCWCD 5
Michael Hilgert
Greenhorn

Joined: Apr 23, 2010
Posts: 17
Page 270, Question 3, Line 3
Is it your right intention to put a comma after the 2 like {1,2,}?

Page 317, Question 8 you use "boolean b2" and at page 324 it is a "Boolean b2"

Page 577, the 4th big point line two ", wich is passed as the second argument" should be "third argument"

Page 581, last section before Using Sets: "In a few pages Table 7-5" should be "Table 7-7" (on page 594)
Ancat Dubher
Greenhorn

Joined: Jul 27, 2008
Posts: 1
Another one.

The Exam Watch box on page 563 says "HashSet and LinkedHashSet must override hashcode(), else Set might allow objects that could be meaningfully equal". This should really say the equals() method, rather than the hashcode() method.
Andreas Schreiber
Greenhorn

Joined: Jun 17, 2010
Posts: 5
Larry Chung wrote:Chapter 6 Self Test, Question 7, page (unknown because I am using an online version of K&B).

INCORRECT:
"...and the output is ''false true''; which set(s) of code fragments must be inserted? (Choose all that apply.) "

CORRECT:
"...and the output is ''false false''; which set(s) of code fragments must be inserted? (Choose all that apply.) "


I don't agree. The INCORRECT sentence is actually correct, because in the second iteration of the for loop path is "dir2" and args[0] is "file2.txt", so the file exists and is a file, so "true" is printed.
Andreas Schreiber
Greenhorn

Joined: Jun 17, 2010
Posts: 5
Ancat Dubher wrote:Another one.

The Exam Watch box on page 563 says "HashSet and LinkedHashSet must override hashcode(), else Set might allow objects that could be meaningfully equal". This should really say the equals() method, rather than the hashcode() method.


True, but then hashcode() must be overridden as well, see page 554. My proposal for the whole text:
When using HashSet or LinkedHashSet, the objects you add to them must override equals() and hashcode(). If they don't override equals() and hashcode(), the default Object.equals() or Object.hashcode() method will allow multiple objects that you might consider "meaningfully equal" to be added to your "no duplicates allowed" set.
Andreas Schreiber
Greenhorn

Joined: Jun 17, 2010
Posts: 5
Jerome Jacobsen wrote:Chapter 6, Self Test Question #11, p. 537

Your explanation states the B would be correct if a char[] was used instead of a String. For B to be correct it would have to look like this:

username: fred
hello fred
password:

It is missing the "hello fred" that was output on line 8 of the code.


To preserve the presumed intent of the question a better change would be to remove line 8 completely from here and on page 523.
Jan de Ruiter
Greenhorn

Joined: Jan 12, 2008
Posts: 12
Andreas Schreiber wrote:
Jerome Jacobsen wrote:Chapter 6, Self Test Question #11, p. 537

Your explanation states the B would be correct if a char[] was used instead of a String. For B to be correct it would have to look like this:

username: fred
hello fred
password:

It is missing the "hello fred" that was output on line 8 of the code.


To preserve the presumed intent of the question a better change would be to remove line 8 completely from here and on page 523.


If char[] was used instead of a String, there would still be another syntax error on line 10: semicolon expected.
The 'if' body is just a comment, and this is not allowed.
Colleagues of mine argue that the comment '// check for valid password' should be understood to represent some code
checking the validity of the password, but that is reading something into it, that is not there.
The code as it is presented, does produce a syntax error at line 10 (i tried it).
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
Hi Guys,

First off, thanks for taking the time to post these errata!

Second, I'd like to request that before an entry goes on this list, it's discussed in a separate thread - to be sure it's actually an error.

Thanks,

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Andreas Schreiber
Greenhorn

Joined: Jun 17, 2010
Posts: 5
Ok, Bert. I have opened a thread called "Discussing errata for K&B, SCJP 6".

First, let me say: Your book was really a great help for my exam preparation. I passed the SCJP exam with 91% in march 2010.

Here comes a list of errors that seem definite:
Page 351: "autoboxing the Long objects" should be "autounboxing ..."
Page 438: String x = " hi "; There are too many blank chars in the String. The number of blank chars must match the corresponding number in the comment // result is " hi x"
Page 506: System.out.printf("%2$d + %1$d", 123, 456); Likewise, there must only be one blank char left and right of the + to match the output on page 507

[Edit:Added link to the relevant thread - Ankit]
Andrea Chiavazza
Greenhorn

Joined: Jul 02, 2010
Posts: 14
Page 583, middle of page:

(((Dog)o).name == name)) {

should be

(((Dog)o).name.equals(name))) {
Alexander Exner
Greenhorn

Joined: Jul 30, 2010
Posts: 10
Page 194 (top):

No cast is needed in this case because d double can hold every piece of information that a long can store.

vs.

9223372036854775806
9223372036854775807

Some of the bits are victim of exponent...

Page 192 (bottom):

byte c = b + c
should be
byte c = a + b
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Alexander I agree on the byte c = b + c thing.

The other problem relating to long-double cast is not a mistake in the book. Floating point values can be truncated sometimes. Before you post an errata in this topic, you can post the error in this topic to make sure if what you think is an error in the book is actually an error in the book...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ekim Retrop
Greenhorn

Joined: Oct 07, 2005
Posts: 3
From Martin Leon
Chapter 10 Self Test, Question 11, page 817, 818.

Foo.java declares that Foo is in the package myApp.

GetJar refers to "Foo.d" but does not either import myApp.* or refer to Foo.d by its fully qualified name. There is no way to get this code to compile.


Amazingly, the PDF version of the book has "Foo.d", and the actual hardcopy version of the book has the correct "myApp.Foo.d"
Either way, none of the solutions are correct for this question.

proper answer in other coderanch posting

Always confidence inspiring when you think you've finally got a grip on something, and then see their answer and think - how the &#*# can that be right?
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Page 9..5th line getStopped() should be replaced with setStopped()..setStopped() is valid java bean method. Please advice if there is any link with updated change list.


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Harikrishna, that line is talking about *getters* for boolean properties, that's why getStopped and isStopped both are listed there. setStopped is a setter java bean method...
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
I got it. Thanks Ankit.
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi, I do NOT see Car class defined in Page 625. But Car instance is created in TestRental class.
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
As per the discussion at this link, http://www.coderanch.com/t/515256/java-programmer-SCJP/certification/Ridiculous-generics-page ranchers are saying that code looks good. But K&B mentioned that it is "ridiculous" code. I would request you to delete it from book (or) please share your thoughts if it is valid point
Peter Ojinuka
Greenhorn

Joined: Jun 26, 2009
Posts: 11
please ranchers let someone send a copy of K & B errtta for SWCD(j2ee).
my email is : blispet4real@yahoo.com
Thanks alot.
fadi aboona
Ranch Hand

Joined: Apr 25, 2010
Posts: 71
Page: 136 Chapter 2.
It says:
How do you know what the default constructor will look like?
Because....

The default constructor has the same access modifier as the class.

I wrote a public class with a private constructor and the code complied just fine.

in fact page 133 says:
Constructors can use any access modifier, including private.

Anyone can confirm this?
Thanks,
Francisco J. Bermejo
Greenhorn

Joined: Mar 02, 2011
Posts: 27

fadi aboona wrote:Page: 136 Chapter 2.
It says:
How do you know what the default constructor will look like?
Because....

The default constructor has the same access modifier as the class.

I wrote a public class with a private constructor and the code complied just fine.

in fact page 133 says:
Constructors can use any access modifier, including private.

Anyone can confirm this?
Thanks,


Hello fadi, I think the book is correct. The default constructor is automatically generated by the compiler only when you don't type a constructor by yourself. And yes, the default constructor will have the same access modifier as the class.

Hope it helps!

PS: by the way you should post any errata which is not confirmed in this thread: http://www.coderanch.com/t/499740/java-programmer-SCJP/certification/Discussing-errata-SCJ


OCPJP 6 96%
fadi aboona
Ranch Hand

Joined: Apr 25, 2010
Posts: 71
Francisco J. Bermejo wrote:
fadi aboona wrote:Page: 136 Chapter 2.
It says:
How do you know what the default constructor will look like?
Because....

The default constructor has the same access modifier as the class.

I wrote a public class with a private constructor and the code complied just fine.

in fact page 133 says:
Constructors can use any access modifier, including private.

Anyone can confirm this?
Thanks,


Hello fadi, I think the book is correct. The default constructor is automatically generated by the compiler only when you don't type a constructor by yourself. And yes, the default constructor will have the same access modifier as the class.

Hope it helps!

PS: by the way you should post any errata which is not confirmed in this thread: http://www.coderanch.com/t/499740/java-programmer-SCJP/certification/Discussing-errata-SCJ


Hi Francisco,

I find that paragraph on page 136 to be misleading because default constructor is not necessarly the one supplied by the JVM. It should have said the default implicit constructor.


Thanks for the link.
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
Page 716, Exam Watch block: Thread.getId() is mistakenly called getld()
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
bump

Hey Guys,

At long last I've started working on an organized errata list for K&B 6. Should be ready soon.

In the meantime this list is pretty good, if unorganized.

thanks,

Bert
Achilleas Achix
Ranch Hand

Joined: Apr 18, 2011
Posts: 123

Chapter 4 question 2.
Correct answer : FOUR will compile , TWO will be true:



OCPJP 6.0
Hwee Su
Greenhorn

Joined: May 29, 2011
Posts: 1
Chapter 2 Self Test Question 11 on page 167 and again on page 178.
Line 4. of the code should read

instead of


As is, none of the listed answers are correct.
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
Can this thread be made a sticky so new ranchers can find it easily?
Sven Mathijssen
Greenhorn

Joined: Aug 29, 2010
Posts: 19
I might have found another one. On page 259 of the book [1] it says:


In the preceding example, we created a method called getDate() that returns a Date object. This method creates two objects: a Date and a StringBuffer containing the date information. Since the method returns the Date object, it will not be eligible for collection even after the method has completed. The StringBuffer object, though, will be eligible, even though we didn't explicitly set the now variable to null.


I don't think the fact that the getDate() method *returns* the Date object is the cause of the Date object not being eligible for garbage collection. It occurs to me that it is only the fact that assigning the result of the getDate to a local variable (Date d = getDate()) would postpone the eligibility for garbage collection to the end of the main method, keeping the Date object alive. If the return value of the getDate() method would not have been assigned to a local variable, it would be eligible for garbage collection right after the method getDate() returns.

Is this correct?

Sorry for violating the copyright by quoting the sentence here.

[1] Sierra K., Bates, B. SCJP Sun (r) Certified Prgorammer for Java (tm) 6 Study Guide (Exam 310-065), McGraw-Hill publishing, ISBN 978-0-07-159108-9.
Robert Lilly
Greenhorn

Joined: Apr 12, 2011
Posts: 1

Bert Bates wrote:bump

Hey Guys,

At long last I've started working on an organized errata list for K&B 6. Should be ready soon.

In the meantime this list is pretty good, if unorganized.

thanks,

Bert


Any progress with the compiled list? I'm just beginning my studies for the OCJP 6 with the K&B 6 book. It would be helpful if I had an organized list of the errata to make notes for in my book.

Thanks,

Robert


Robert Lilly
Chris Falter
Greenhorn

Joined: Sep 16, 2011
Posts: 1
Question 67 in the LearnKey MasterExam is incorrect because of bad grammar. It is a "check all correct" question, and one of the possible answers is "A jar file can contain classes from only a single package." The test considers this to be incorrect, presumably because the *intention* is to make the adverb "only" apply to the verb "can...contain." I.e., the intention was for the answer to claim that a jar file is not allowed to contain classes from more than one package, which is indeed false.

However, the statement is *true* as written, because the adverb "only" applies to the preposition "from." Read this statement carefully:

"My jar file contains classes from only a single package, the com.foobaz.utils package."

It is legal for a jar file to contain classes from only a single package, just as it is legal for a jar file to contain classes from many packages. So the statement is true. As is the logically equivalent statement that "A jar file can contain classes from only a single package," as in "It is possible for a jar file to contain classes from only a single package."

A correct phrasing of the *intention* would be as follows:

"A jar file may only contain classes from a single package." The grammar is fixed, the new statement is false, and the world is a better place.

dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
Robert Lilly wrote:
Bert Bates wrote:bump

Hey Guys,

At long last I've started working on an organized errata list for K&B 6. Should be ready soon.

In the meantime this list is pretty good, if unorganized.

thanks,

Bert


Any progress with the compiled list? I'm just beginning my studies for the OCJP 6 with the K&B 6 book. It would be helpful if I had an organized list of the errata to make notes for in my book.

Thanks,

Robert


Robert, I think it's pretty clear after four years that this thread is as much as we can expect.
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

Bert,

Are these errata organized by chapter number and by page number anywhere?

-- Kaydell
Roel van Dun
Greenhorn

Joined: Jan 30, 2012
Posts: 1

Self Test chapter 2, answer of question 15 states: "In general, overloaded var-args methods are chosen last."
This information is not given until chapter 3, page 250. So why does chapter 2 test this?

Self Test chapter 3, answer of question 11 on page 285 states:
"What might be less clear is that you can still access the other Beta object through the static variable a2.b1 - because it's static."
Shouldn't this be a1.b1?
imad belhasus
Greenhorn

Joined: Mar 05, 2010
Posts: 5
Hi all,

I'm preparing for the SCJP too, and I found a mistake please correcte me if I'm wrong, in self test for chapter 3 question number 7 ..


Which are true? (Choose all that apply.)
A. The output could contain 30
B. The output could contain @bf73fa
C. The output could contain DIAMONDS
D. Compilation fails due to an error on line 6
E. Compilation fails due to an error on line 7
F. Compilation fails due to an error on line 8
G. Compilation fails due to an error on line 9
H. Compilation fails due to an error within lines 12 to 14

when I compiled this code i've got an error compilation line 12 the methode getBidValue not found. so that mean H is the correct awnser, but their solution says that it compile fine and the correct awnsers are A and B .. any updated Errata for this book ??
Rik Roos
Greenhorn

Joined: Feb 06, 2012
Posts: 13
If not already mentioned but on page 246 ( object equation by autoboxing):

Last bullet :
Short and Integer from -128 to 127


This should be:

Short and Integer and Long from -128 to 127
Adam T. Nagy
Greenhorn

Joined: Mar 14, 2012
Posts: 1

Hello!
First! Thank you for the book it helped me a lot learning and taking the exam. Second. Please keep your fingers crossed, I am going to an interview regarding a junior java programmer position. :-) It is extremely important for me because I had to make a career change lately and five months ago I didn't even know what a class was... :-)
And the rest:

Page 41:
2nd code fragment uses the name: recordNumber() instead of recNumber()

Page 114:
TABLE 2-2 Uses the name of the previous table (2-1) which is "Examples of Illegal Overrides". Should be named something like: "Which overridden/overloaded methods to use"

Page 191: middle of the page says:
"(it's a pointer to something, we just don't know what that something really is)"
But then Page 289 says:
"(We know all you C++ programmers are just dying for us to say "it's a
pointer", but we're not going to.)"

Page 510: middle of page:
"... regular expressions (Regex). regex expressions can be ..." should be written like this:
"... regular expressions (regex). Regex expressions can be ..."

Page 551:
Uses the names "Amy and May" but it is misleading because on the previous page in FIGURE 7-1 it uses "Alex" and "Dirk" instead.

Page 707: Missing semicolon in the first code fragment:
MyThread t = new MyThread()

Thanks again, cheers, Adam.
Yalvin Duha
Ranch Hand

Joined: Apr 07, 2012
Posts: 40

Rik Roos wrote:If not already mentioned but on page 246 ( object equation by autoboxing):

Last bullet :
Short and Integer from -128 to 127


This should be:

Short and Integer and Long from -128 to 127

I thought this is more of a vendor-specific implementation, but since the exam is with "Sun's" (6), and perusing the source code (albeit the one downloaded with 7.0_02) indicates that it does indeed have such range cached.


So, you could certainly add Long class to the aforementioned list.
Mateusz Blaz
Greenhorn

Joined: Jun 13, 2012
Posts: 1
Hello All,

It seems to me that on MasterExam questions there are some errors. Please find my list of finding below:

Obvious errors:

Test B, question 52:

E: Has-A relationship is always based on instance variables

Expected answear is false, and in reference it is stated:
(...) E is incorrect because class variables (statics) can also be used to define has-a relationships

Test C, question 4:

B: Has-A relationships always rely on instance variables
Expected answear is true, and a reference says:
EXPLANATION:
B is correct

So, the same statement is true and false at the same time? ;)

Test C, question 43:
Obvious typo, The question is about how to sort list with elements " x", "Xx", "xx", but the question says we should get a result "x", "Xx", "Xx". Unfortunatelly this typo made it impossible to answear the question correctly.

More subtle issues:

Test C, Question 66:
A: The java command can access classes from multiple jar packages, from a single jar file
Expected answear is true. IMO should be false, as java command can access classes from multiple jar files

Test B, Question 30:
B: When an object is serialised, if it has references to other objects, those objects must be serializable
expected answear is true. IMO should be false, as transient keyword allows referencing not-serializable objects

Test B, Question 18:
E: Never throw AssertionError explicitely
Expected answear is false, but throwing this error not through assertions (so that we cannot disable it using java command switch on production environment) or JUnit (so that error is raised only in test classes) seems to be a very bad idea.

Test B, Question 66:
E: when using java command, only files ending with .class can be executed
Expected answear is true, but what about java -jar executable.jar? Of course, there is a .class file somewhere inside this jar, but the extension of executed file is jar.

Test A, Question 42:
Which is more tightly coupled: A: new BioDiesel() or D: new BioDiesel(new Velocity())?
Expected answear is D: but, objects are less tightly coupled if instances are injected as a constructor parameter (so that we can use polymorphism and pass other object with the same API) than when they are constructed somewhere inside the class. Thus, I'd mark A as most tightly coupled.

Test A, Question 50:
A: Is-A relationship always rely on inheritance
Expected answear is true, but Is-A can also rely on interfae implementation. I'm taking into consideration the fact, that test uses it's own definitions of concepts such as IS-A, coupling etc, but even in the SCJP study guide (Chapter 2, page 92) it is stated:
You express IS-A relationship in Java through the keywords extends (for class inheritance) and implements (for interface implementation) - so I understand that inheritance and interface implementation are considered different concepts (They should be, as far as I'm concerned)

C: Is-A a relationships always require at least two class types?
Expected answear is true, which is correct only if we assume that interface is a class type. Maybe it's just me, but while reading the question I wasn't sure we can make such a assumption

E: Is-A relationships are always tighlty coupled.
In my opinion:
If we assume that answear A is true, then we are assuming that IS-A relationship means class inheritance. Class inheritance means very tight coupling (and that's where decorator or strategy patters come to play).

Any remarks/corrections are very welcome!

Best regards,
Mateusz
Bob Condon
Greenhorn

Joined: Jun 17, 2012
Posts: 2

Ch. 3 Qn. 12
My output was "4 6" - which is not a choice in the book.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiling errata for K&B, SCJP 6