• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

K&B Chapter 1: Self Test Query on Javabeans standard (confusion)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Query on the question

Which methods name follow the javabeans standard

A: addSize
B: getCust
C: deleteRep
E: isColorado
E: putDimensions

The answers state that only B and D are correct.

However

The Two Minute Drill States

JavaBeans methods must be named in camelCase and depending on the method's purpose must start with set, get, add or remove

This would mean that A is also correct

So which one is right?

Thanks

J
 
Jay Stryper
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. This is the K&B book for SCJP 5 - I've got the 6 book on order.

Cheers
 
Ranch Hand
Posts: 537
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
add and remove can be used for methods of Listeners only according to Javabean standards.
 
Ranch Hand
Posts: 196
Android Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jay Stryper wrote:Query on the question
JavaBeans methods must be named in camelCase and depending on the method's purpose must start with set, get, add or remove

This would mean that A is also correct

J



add and remove are used for listeners and components in AWT and JFC in most cases.....
and
it is also obvious that you are not going to add size but only set it......... add doesn't make any sensse in this context.....
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because in javabeans you use only set and get methods to store and retrieve attributes .And isXXX method to retrieve the boolean value.
So the B & D options only satisfy.
 
Arthur, where are your pants? Check under this tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic