JAVA BEANS
JavaBean is a reusable software component written in Java.
It follows certain conventions so that it can be easily used, configured, and manipulated in tools
(like IDEs or frameworks).
JavaBeans are classes that encapsulate many objects into a single object
(the bean). It is a Java class that should follow the following conventions:
1. Must implement Serializable.
2. It should have a public no-arg constructor.
3. All properties in java bean must be private with public getters and
setter methods.
Setter and Getter Methods in Java
Setter and Getter Methods in Java properties are mentioned below:
Properties for setter methods:
1. It should be public in nature.
2. The return type a should be void.
3. The setter method should be prefixed with the set.
4. It should take some argument i.e. it should not be a no-arg method.
Properties for getter methods:
1. It should be public in nature.
2. The return type should not be void i.e. according to our
requirement, return type we have to give the return type.
3. The getter method should be prefixed with get.
4. It should not take any argument.
// Java program to access JavaBean class
package geeks;
// Driver Class
public class Test {
// main function
public static void main(String args[])
// object is created
Student s = new Student();
// setting value to the object
[Link]("GFG");
[Link]([Link]());