wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Kathy Sierra book - doubt - javaBeans name convention Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Kathy Sierra book - doubt - javaBeans name convention" Watch "Kathy Sierra book - doubt - javaBeans name convention" New topic
Author

Kathy Sierra book - doubt - javaBeans name convention

Marcelo Ribeiro
Greenhorn

Joined: Aug 04, 2007
Posts: 9
Hello,

Kathy's book page 68 says:


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


and on the self test it says:


A, C, and E are incorrect because 'add', 'delete' and 'put' are not standard JavaBeans
name prefixes. (Objective 1.4)


could anyone please explain what I lost because, first it says that "add" should be used then says it should not.

Thanks in advance!
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Read again properly. It says 'add' can be used with Listener methods. And in example it uses 'add' with no Listener method.

I think I make you clear.


SCJP-1.5<br />SCWCD-1.4
Marcelo Ribeiro
Greenhorn

Joined: Aug 04, 2007
Posts: 9
thanks for the explanation, but it is not so clear yet, at these examples:

public void removeMyListener(MyListener m) //correct

public void addXListener(MyListener m) // listener type mismatch


at books's question the option where we have add is:

addSize


if it was
addListenerSize


would it be correctly?

Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Kathy Sierra book - doubt - javaBeans name convention
 
Similar Threads
Java Beans Question
An error in the K&B SCJP5 book?
JavaBeans method name prefixes
Wrong answer in K&B SJCP 5 self test 1.2?
Ambiguity in Kathy Sierra Question