Lukasz Jarocki wrote:I think option C is incorrect.
You are wrong, option C is correct! But I definitely understand your confusion
Let me try to clear your doubts.
In the JavaBeans specifications/convention there is no requirement between the property name and the instance variable you use to store the value for this property. So there could be a difference between the instance vaariable name and the property name (although in most cases both will mqtch). Take a look at this example:
So the class
JellyBean supports a property "color" and its value is stored in the instance variable
ourColor and this is completely valid according to the JavaBeans specifications (in fact, this example is a simplified version from
the JavaBeans specifications itself
)
Back to the questions now:
So the property is "numWings" and the value is stored in the instance variable
numberWings. Because the property is "numWings", the setter method (if present) must be
setNumWings; any other name would be invalid according to the JavaBeans specifications.
Finally I like to add that answer A is correct as well (as already mentioned in
the official errata overview of the study guide).
Hope it helps!
Kind regards,
Roel