What is a java bean?

What is a java bean?

JavaBeans is an API reusable, platform indepent component writtenin java programming language. 

A JavaBean is a simple class havingthe setter and getter methods for each property. 

It is good convension to implement the Serializable interface.


  import java.io.*;

public class MyBean implements Serializable {

// Properties private String name = null; private int age = 0; // Getter and Setter Methods

public String getName() { return name; } public void setName(String s) { name = s; } public int getAge() { return age; } 

public void setAge(int i) { age = i; } }

Date:2011-01-09 00:00:00

Post Your Answers

User Email:

User Name:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher