• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

contradictory statements

 
Saurabh V Vakil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the SCJP Sun Certified Programmer for Java 5(Exam 310-055) Exam Study Guide, the two minute drill in the first chapter(Identifiers (Objective 1.3) )states that methods following the JavaBeans Standards must start with set, get, is, add or remove.
Question number 5 of the same chapter's self test asks us to identify method names that follow the JavaBeans standard :
A. addSize
B. getCust
C. deleteRep
D. isColorado
E. putDimensions

The answer given in the Self Test Answers says the answer is options B and D along with the explanation that 'add' is not standard JavaBeans name prefix.
Now isn't there a contradiction here???
Is 'add' a JavaBeans standard prefix or not?
 
Serg Masow
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saurabh,

there is no contradiction. The prefix add can also be used. But just add a listener. In such a case the method name must begin with add and ends with word "Listener" and have the same listener type as argument. So a valid method declaration can be:

public void addSomeListener(SomeListener ls);

please look into the K&B book on the page 9 (JavaBean Listener Naming Rules) for further explanation.

Serg
 
Saurabh V Vakil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Serg. I got the point.
 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And saurabh, be careful with this as you can expect questions based on this understanding on the actual exam
 
Saurabh V Vakil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jitendra Jha:
And saurabh, be careful with this as you can expect questions based on this understanding on the actual exam


Yes I will be. Thanks for the reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic