Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JavaBean naming standard  RSS feed

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

The following are the question, answer and explanation for an objective 1 question taken from the KS &BB study guide page 74.

2. Which method names follow the JavaBeans standard? (Choose all that apply.)

A. addSize
B. getCust
C. deleteRep
D. isColorado
E. putDimensions


Answer:
- B and D use the valid prefixes 'get' and 'is'.
- A is incorrect because 'add' can be used only with Listener methods. C and E are
incorrect because 'delete' and 'put' are not standard JavaBeans name prefixes.
(Objective 1.4)



My question is, so what if add can be used only with Listener methods? The question did not ask for method names following JavaBeans standard applying to non-Listener methods. I understand from the KS&BB book, page 9:

JavaBean Listener Naming Rules

■ Listener method names used to "register" a listener with an event source
must use the prefix add, followed by the listener type. For example,
addActionListener() is a valid name for a method that an event source
will have to allow others to register for Action events.



Since it's listed under JavaBean Listener Naming Rules dosen't add become JavaBean standard? Hope somebody can explain. Thanks.

regards
John
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, Java Beans used to set/get particular value of the instance variable of the defined class.
For example, instance variable customer, than void setCustomer(){} and int getCustomer(){}

And for boolean instance variable(for example colorado), it will check its status with isVariableName(for example isColorado() ).
 
Gaurangkumar Khalasi
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
addXxxListerner()
removerXxxListener()

are valid javabeans conventions for adding and removing listeners.

But removeX() or addX() are not JavaBeans naming standards.

For more information:
http://www.coderanch.com/t/262282/java-programmer-SCJP/certification/JavaBeans-naming-standard
http://www.coderanch.com/t/257589/java-programmer-SCJP/certification/SCJP-Errata-Updated
 
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Gaurangkumar Khalasi wrote:addXxxListerner()
removerXxxListener()

are valid javabeans conventions for adding and removing listeners.

But removeX() or addX() are not JavaBeans naming standards.

For more information:
http://www.coderanch.com/t/262282/java-programmer-SCJP/certification/JavaBeans-naming-standard
http://www.coderanch.com/t/257589/java-programmer-SCJP/certification/SCJP-Errata-Updated



Nice.:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!