• 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

boolean variable getting method keywords

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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。。。
 
No, tomorrow we rule the world! With this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic