Hi, I came across one confusing thing when studying for exam, I will quote from study book I am using. One of the naming conventions is described as follows:
The method name must have a prefix of set/get/is, followed by the first letter of the property in uppercase, followed by the rest of the property name.
Now there is a review question asking for which method declarations follow those conventions, one of the options is this:
This option is marked as one of the correct answers. However, according to the description above, name should start with get (correct) upper case first letter of property name (correct) and then followed by rest of the property name - and this part is incorrect. Body of getter suggests that property name is "numberWings" which would mean that proper name should be getNumberWings and not getNumWings according to conventions.
Am I correct in thinking that such option is actually incorrect answer or am I missing something?
That's our book. The text is incorrect on the explanation of JavaBeans. The answer is A, C and E. (There's an errata on ch 4 question 9)
The big thing to note is that the property name is just what is in the method name. It doesn't need to correspond to the instance variable name.
Also worth noting is that JavaBeans aren't on the exam. They used to be and we were worried Oracle would put them back on after we printed. It's been over a year and they still aren't back so you are safe!