Page 1 of 1

About question com.enthuware.ets.scjp.v6.2.13

Posted: Sun Apr 03, 2011 2:02 pm
by fordern
public class Bond
{
public String ticker;
private double Coupon;

public String getTicker()
{
return ticker;
}

public void setTicker(String ticker)
{
this.ticker = ticker;
}

public double getCoupon()
{
return Coupon;
}

public void setCoupon(double coupon)
{
//do nothing
}

public java.util.Date getMaturity()
{
return new java.util.Date();
}

public boolean isFloater(){ return false; }

public boolean getCallable(){ return true; }

}

I thought the JavaBean naming convention for boolean retrieval was isCallable not as the answer states getCallable().

I would hate to get such a simple question wrong on the real exam, what do others think?

Re: About question com.enthuware.ets.scjp.v6.2.13

Posted: Sun Apr 03, 2011 2:51 pm
by admin
As the explanation says, for a boolean property, both - isXXX and getXXX, are valid.

Re: About question com.enthuware.ets.scjp.v6.2.13

Posted: Sun Apr 03, 2011 4:20 pm
by fordern
OK Thanks

Re: About question com.enthuware.ets.scjp.v6.2.13

Posted: Mon Dec 03, 2012 6:01 pm
by Guest
and what about this.


isCallable should return boolean and
getCallable() should return Boolean.

at least idea intellij generate code like this

Re: About question com.enthuware.ets.scjp.v6.2.13

Posted: Tue Dec 04, 2012 6:00 am
by admin
Guest wrote:and what about this.


isCallable should return boolean and
getCallable() should return Boolean.

at least idea intellij generate code like this
Since a boolean can be autoboxed into Boolean, this doesn't really matter. Further, I am not sure whether what intellij is doing is really the convention.

HTH,
Paul.