*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes boolean variable getting method keywords Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "boolean variable getting method keywords" Watch "boolean variable getting method keywords" New topic
Author

boolean variable getting method keywords

Jingxian Zhou
Greenhorn

Joined: Jun 22, 2010
Posts: 28


Answer:A,
Explanation :
The correct option is a java bean naming standard

I selected A and B。
Why B is not the correct answer?

Thanks!


PS:
This question quoted from CertPal SCJP1.6 Moke Exam


SCJP6(310-065) with 96%, SCWCD (310-083) with 89%, SCBCD 5 (310-091) with 98%
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Please QuoteYourSources. Where does this question come from ? If it's a book, which book. If it's a mock, which mock.


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

If the question is about JavaBeans (it looks like it), the convention for boolean getters is to name them "isXXXX", not "getXXXX".

From the JavaBeans spec:
8.3.2 Boolean properties
In addition, for boolean properties, we allow a getter method to match the pattern:

public boolean is<PropertyName>();

This "is<PropertyName>" method may be provided instead of a "get<PropertyName>" method, or it may be provided in addition to a "get<PropertyName>" method. In either case, if the "is<PropertyName>" method is present for a boolean property then we will
use the "is<PropertyName>" method to read the property value. An example boolean property might be:

public boolean isMarsupial();
public void setMarsupial(boolean m);
Jingxian Zhou
Greenhorn

Joined: Jun 22, 2010
Posts: 28


Above quote from SCJP Study Guide(Exam 310-065)


So,I think B maybe correct
Jingxian Zhou
Greenhorn

Joined: Jun 22, 2010
Posts: 28
Christophe Verré wrote:Please QuoteYourSources. Where does this question come from ? If it's a book, which book. If it's a mock, which mock.


First,thank you for reply.

Er..I hope you do not reply this every time.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

One day I'll learn to read what I post The specification says "This "is<PropertyName>" method may be provided instead of a "get<PropertyName>" method", so answer B looks right too.

Er..I hope you do not reply this every time.

As long as you quote your sources
Jingxian Zhou
Greenhorn

Joined: Jun 22, 2010
Posts: 28
Christophe Verré wrote:One day I'll learn to read what I post The specification says "This "is<PropertyName>" method may be provided instead of a "get<PropertyName>" method", so answer B looks right too.

Er..I hope you do not reply this every time.

As long as you quote your sources



Thanks a lot!

This question quoted from CertPal SCJP1.6 Moke Exam

I explained quote。。。
 
Don't get me started about those stupid light bulbs.
 
subject: boolean variable getting method keywords
 
Similar Threads
Java Beans naming standards question
JSTL over a Set: Did not get data as expected
CertPal question (JavaBean naming standards)
transient property gets "cached" when called from rich:tree