This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JavaBeans 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 "JavaBeans" Watch "JavaBeans" New topic
Author

JavaBeans

Tim Eapen
Greenhorn

Joined: May 28, 2006
Posts: 22
Hello everybody:

I have recently started studying for the SCJP exam. The first chapter of the book I am using talks about JavaBean conventions, specifically for providing getters and setters for all private instance data (properties). Do you have to provide getters AND setters for all properties. The reason I ask is that I came across the following code on another site and they call it a bean:



Notice that they don't provide getters and setters for all their properties. Is this a bean?

thx,
Tim
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Its not a java bean.

Sun has set some naming convention for java bean

1. For bean property x, method should be setX, getX. For boolean field, you can use getX or isX.

2. For listener, method signature should be addX and removeX.

Your bean does not define setters/getters even for a single field. If you execute this bean on say bean development kit popularly known as BDK, you can't get the value of dirname which you have set by setter. Because there is no getter for that.


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaBeans
 
Similar Threads
searching a file in hierarchy and delete
Illegal Argument exception
What is Encapsulation
why it throws NullPointerException
JFileChooser override