Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JavaBean standard question from Sierra's book

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Self Test of Chapter 1 in Sierra's book there is a question:

Which method names follow the JavaBeans standard?
A. addSize
B. getCust
C. deleteRep
D. isColorado
E. putDimensions

In Self Test Answers there is an info that B and D are correct but A, C and E are incorrect, because 'add', 'delete' and 'put' are not standard JavaBeans name prefixes.

The point is that in Chapter 1 [page 10 and 11] it is written that there are valid JavaBeans names with 'add' prefix.


My question is: are these answers and explanations to the question quoted above correct?
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javabeans prefix for methods are only get/set for getter and setters.
If a property is a boolean a getter can be is:
Example
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The add, remove JavaBean prefixes are intended for adding and removing Listeners, thus must be appended by Listener name.
 
Ranch Hand
Posts: 46
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add and remove are valid java bean prefixes while using with listeners only.
The explanation for the self test answer is wrong.
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic