Pages

POJO class in Java

POJO  :  Plain Old Java Object

 

POJO : 

1. It is an ordinary clasess.

2. The classes that does not implement any technology/framework  api interfaces and that does not extend  any technology/framework  api classes.

3. It can extends and implement from java language.

Examples

Example 1
class Demo { 
  
// implementation goes here

}

Given class is POJO because it is simple java language class
Example 2
class Demo extends HttpServlet {

// implementation goes here

}

Given class is Not POJO because it extend Servlet technology class
Example 3

class Demo implents Serializable {

// implementation goes here

}


Given class is POJO because it implement java language serializable

Example 4
@Entity
class Demo {

// implementation goes here

}

// Given class is POJO, 
//if a class uses only annotation then it is POJO 
Example 5
class Demo extends Test {

// implementation goes here

}
// if Test is POJO, Demo also POJO