wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes CertPal question (JavaBean naming standards) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "CertPal question (JavaBean naming standards)" Watch "CertPal question (JavaBean naming standards)" New topic
Author

CertPal question (JavaBean naming standards)

Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

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


"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

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


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CertPal question (JavaBean naming standards)