This week's book giveaway is in the Java in General forum.
We're giving away four copies of Java by Comparison (eBook) and have Simon Harrer, Jörg Lenhard, Linus Dietz on-line!
See this thread for details.
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

contradictory statements  RSS feed

 
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?
 
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.
 
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.
 
Why is the word "abbreviation" so long? And this ad is so short?
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!