Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An error in the K&B SCJP5 book?

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an entry in the K & B Errata (for page 9) explaining that prefix "add" must be used in the form "addXXXListener".
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the above new error noticed anyway?
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm thinking about it - and it's not as clear-cut as it might seem
 
Naresh Devasani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic