• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

JavaBeans conventions

 
Greenhorn
Posts: 2
Android IntelliJ IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks in advance for your help and time
 
author & internet detective
Posts: 39348
755
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jozef,
Welcome to CodeRanch!

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!
 
Jozef Paľa
Greenhorn
Posts: 2
Android IntelliJ IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for fast response And yeah, seems like your book
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jozef Paľa wrote:Am I correct in thinking that such option is actually incorrect answer or am I missing something?


That question is already asked a few times in this forum. This topic has probably the most elaborate discussion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!