Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

1Z0-808 Naming conventions getters/setters

 
Greenhorn
Posts: 7
IntelliJ IDE Angular Framework Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

In chapter 4 in table 4.5 about naming conventions I read that "Getter methods begin with IS or GET if eht property is BOOLEAN." In the summary of chapter 4 is stated that "Javabeans use methods beginning with IS and GET  for BOOLEAN and NON_BOOLEAN property type, respectively." These 2 lines contradicts.

Besides that, question 9 in the book and question 9 at Wileys testbanks about the naming conventions are exactly the same. But the answer in the book differ from the answer at Wileys testbanks. The book uses the theory of the table, the online question the theory of the summary. S

So I have the following questions:
1. Is it possible that the theory in table 4.5 and the summary are explained the same way.
2. Is it possible that the book and the online quizz give the same answer and last but not least
3. Can someone explain to me which is right. Table 4.5 or the summary?

Greetings,
Jan
 
Marshal
Posts: 69373
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please give us full details of the book, so we know which one it is, and also details of questions if appropriate. Remember that many readers haven't got that book. The first quote does appear to be ambiguous, but have you quoted it exactly?
 
Jan Dales
Greenhorn
Posts: 7
IntelliJ IDE Angular Framework Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ritchie,

The title of the book is:
OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide
By Jeanne Boyarsky and Scott Selikoff

The ISBN: 978-1-118-95740-0

Pagenr of table 4.5: 206
Pagenr of summary: 215, but the specific sentence is on page 216
Pagenr of question 9 in the book: 220

Kind regards,
Jan
 
Campbell Ritchie
Marshal
Posts: 69373
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the details
Methods returning a boolean are usually called isXXX(), hasXXX(), canXXX(), or similar, not getXXX(), so the first quote seems to be the wrong way round, assuming you have copied it exactly. It is “get”, not “GET”, by the way.
The second sentence with “respectively” has them the right way round. Note it is only compulsory to start  boolean get methods isXXX() if you are following the Bean p‍attern.
Please look here; I cannot find such an error being reported previously.
 
Jan Dales
Greenhorn
Posts: 7
IntelliJ IDE Angular Framework Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the explanation.

I typed "GET" and "IS" in uppercase to emphasize them. I know in the real world they should be typed in lowercase. But anyway, I now know what to use with booleans and non-booleans. For me that was the main thing because, to my humble opinion, it is very important to use standards so everyone is able to read my code.

Greetings,
Jan
 
Campbell Ritchie
Marshal
Posts: 69373
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jan Dales wrote:Thank you for the explanation. . . . Jan

That's a pleasure
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic