title: Programming difference between POJO and Bean
body: <p>I have the following two classes. Can I say the first one is a POJO class and the second one as a Bean class?</p>
  
  <p>1) POJO class, since it has only getter and setter method, and all the member are declared as private</p>
  
  <pre><code>public class POJO {
      private int id;
      private String name;
  
      public int getId() {
          return id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setId() {
          this.id = id;
      }
  
      public void setName() {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>2) Bean class - all the member variables are private, has getters and setters and implements <code>Serializable</code> interface</p>
  
  <pre><code>public class Bean implements java.io.Serializable {
      private String name;
      private Integer age;
  
      public String getName() {
          return this.name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Integer getAge() {
          return this.age;
      }
  
      public void setAge(Integer age) {
          this.age = age;
      }
  }
  </code></pre>
  
  <p>It also has a no-arg constructor.</p>