Given the following six method names:
addListener
addMouseListener
setMouseListener
deleteMouseListener
removeMouseListener
registerMouseListener
How many of these method names follow JavaBean Listener naming rules?
A. 1
B. 2
C. 3
D. 4
E. 5
答案:B
參考:7-4 封裝
------------------------------------------------------------------
符合JavaBean Listener的命名規則
addListener
addMouseListener
JavaBean is a reusable software component that can be visually manipulated using the builder tool. The following are the JavaBean Listener naming rules:
回覆刪除•Listener method names that are used to register a listener with an event source must use the prefix add followed by the listener type.
•Listener method names that are used to remove a listener must use the prefix remove followed by the listener type.
•The type of listener to be added or removed must be passed as the argument to the method.
•Listener method names must end with the word “Listener”.