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.)
- 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.
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.