Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JavaBean name convention  RSS feed

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the setter methods below conform to JavaBean name convention? (Not from any mock test)

Thanks!

private int a;

1. void setA(int a) {};
2. protected void setA(int a) {};
3. public void setA(int a) {}
4. public void setA(int x) {}
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think
public void setA(int a)
is the correct setter method of a bean.
You can get more info regarding this on sun website. Just search for java coding convention.
Thanks
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Must be 3, since a setter must be
1-marked public
2-marked void
3-have an argument that represents the property being set.
(I don't think that "int x" represents the property "A")
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!