• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CertPal question (JavaBean naming standards)

 
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I got this Q/A from CertPal mock exam.

Q) If a java bean has a boolean variable named tankFull, how would you provide getters and setters for it?
Options(choose 1):

1) public boolean isTankFull(){return tankFull;}
public void setTankFull(boolean tabkFull){this.tankFull = tabkFull;}

2) public boolean getTankFull(){return tankFull;}
public void setTankFull(boolean tabkFull){this.tankFull = tabkFull;}

3) public boolean getTankFull(boolean tankFull){return tankFull;}
public void setTankFull(boolean tabkFull){this.tankFull = tabkFull;}

4) public boolean gettankFull(){return tankFull;}
public void settankFull(boolean tabkFull){this.tankFull = tabkFull;}

5) None of the above


The correct answer is listed as option 1. But, shouldn't the correct answer be option 2?

Thanks,
Nidhi
 
Ranch Hand
Posts: 400
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, 1 is absolutely correct.
because isTankFull is more meaning full than setTankFull!
we always use "is" with boolean variables into java bean classes.
 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Minhaj kaimkhani wrote:No, 1 is absolutely correct.
because isTankFull is more meaning full than setTankFull!
we always use "is" with boolean variables into java bean classes.



Wow... I didn't know that. Thought it was setX() & getX() for all getters/setters and isX() - an additional(allowed) method. Thanks so much!!!
reply
    Bookmark Topic Watch Topic
  • New Topic