It's not a secret anymore!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes An error in the K&B SCJP5 book? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "An error in the K&B SCJP5 book?" Watch "An error in the K&B SCJP5 book?" New topic
Author

An error in the K&B SCJP5 book?

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I was just sitting down starting to read the SCJP5 book to prepare for my SCJP5 exam, about the next month. A nice book.

In the two-minute drill of the first chapter the following is stated under Identifiers:
JavaBeans methods must be named using camelCase, and depending on the method's purpose, must start with "set", "get", "is", "add" or "remove".
Nothing new yet. This is tested in question 5 of the self-test:
Which method names follow the JavaBeans standard? (Choose all that apply.)
A. addSize
B. getCust
C. deleteRep
D. isColorado
E. putDimensions
Well, I answered A, B and D.

But the answer section of the same book states that B and D are correct and that "add", "delete" and "put" aren't standard JavaBeans name prefixes.

What's wrong here?


Edit: oh, and one more little detail: the answer on question 6 states "A and E use valid var-args syntax". The "E" isn't bold. I guess this have to be bold too?
[ October 15, 2006: Message edited by: Bauke Scholtz ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
There is an entry in the K & B Errata (for page 9) explaining that prefix "add" must be used in the form "addXXXListener".


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
This has nothing to do with this problem, I guess. Also I noted that the most of those errata are solved in my book, at least all of those which doesn't have the * mark (new since April).

Where can I find the current version of my book exactly?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Your answer A is considered incorrect because the option is "addSize" rather than "addSizeListener" which does follow the JavaBeans convention. I have no idea what a SizeListener might do, perhaps listing for an event indicating a window has changed its dimensions. (There would be the corresponding removeSizeListener as another possible option). If that is not what you meant in your original post please restate the problem you are experiencing.

Regarding your question about which is the latest printing of the book, I guess that Bert Bates could give us some information on that. What ISBN number do you have on your copy?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
This is literally citated from the two-minute drill at page 68:
JavaBeans methods must be named using camelCase, and depending on the method's purpose, must start with "set", "get", "is", "add" or "remove".
The "add" is in there, while it should probably be wrong, as it turns out now?


The ISBN of my book is 0-07-225360-6. The P/N is 0-07-225361-4.
[ October 15, 2006: Message edited by: Bauke Scholtz ]
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8805
    
    5
Hi Bauke,

It turns out I'm catching up on errata today

So, what do you think is wrong on page 68? Remember that the two minute drills are just summaries - they can't restate all the tricky in's and out's of everything that's covered in the chapter.

As far as the reprint goes, I believe Osborne will be doing a reprint in the next month or two that should have all known errata fixed. When that schedule is finalized, I'll make a post on this forum.

hth,

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I know it's just a summary. But I don't understand if this is really correct:

Page 68:
JavaBeans methods must be named using camelCase, and depending on the method's purpose, must start with "set", "get", "is", "add" or "remove".


Page 78:
A, C and E are incorrect because "add", "delete" and "put" are not standard JavaBeans name prefixes.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8805
    
    5
Aha!

I think 68 is okay, but I think the explanation for answer 5 on page 78 needs some fixing up - 'add' can be used only with Listeners.

thanks,

Bert
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
One more error:

Boolean.parseBoolean(string) is missing in table 3-3 at page 233. This is new since Java 5. It doesn't support radix, so you need to put an 'x' at Boolean parseXxx only.

In the old ages before Java 5 you have to use new Boolean(string).booleanValue(). Talking about booleanValue() .. This is also missing in the table. It's supported by Boolean only.

Oh, please don't say this is out of the scope for the exam
[ October 20, 2006: Message edited by: Bauke Scholtz ]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Is the above new error noticed anyway?
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8805
    
    5
i'm thinking about it - and it's not as clear-cut as it might seem
Naresh Devasani
Greenhorn

Joined: Oct 26, 2006
Posts: 9
Hi, this is Naresh. Newly joined in this group...

--------------------------------------------------
One more error:

Boolean.parseBoolean(string) is missing in table 3-3 at page 233. This is new since Java 5. It doesn't support radix, so you need to put an 'x' at Boolean parseXxx only.
----------------------------------------------------

It may not be error in the book, since if you put 'x' at Boolean parseXxx, it means that it is a "static method (true), and throws NFException (false)". But if you see the API, it will not throw NFE for Boolean's parseBoolean method.

one more important thing is that, Boolean class has only parseBoolean method. there is no meaning for "Xxx" in parseXxx

Correct me if i am wrong.


Thanks,<br />Naresh
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Originally posted by Naresh Devasani:

It may not be error in the book, since if you put 'x' at Boolean parseXxx, it means that it is a "static method (true), and throws NFException (false)". But if you see the API, it will not throw NFE for Boolean's parseBoolean method.
You're right, it does not throw an NFE. But this method should be there in the table anyhow :P


one more important thing is that, Boolean class has only parseBoolean method. there is no meaning for "Xxx" in parseXxx
This shouldn't matter, it is clear enough where the "Xxx" stands for, if you look to the fields with the 'x'.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An error in the K&B SCJP5 book?
 
Similar Threads
JavaBeans standard method name?
A question in K&B book for SCJP 1.5
Ambiguity in Kathy Sierra Question
contradictory statements
Doubt on a K & B SCJP5 guide question: GENERICS