Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

boolean variable getting method keywords

 
Jingxian Zhou
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources. Where does this question come from ? If it's a book, which book. If it's a mock, which mock.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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


So,I think B maybe correct
 
Jingxian Zhou
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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。。。
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic