Java Basic Examples

Example Employee Class

Here is the Employee class which is used in many of the examples. Employee class has four properties namely id, name, department and age and has getters and setters methods for these properties. Default constructor has also been overloaded to accept id, name and department properties and second overloaded constructor accepts all four properties of an employee.

Employee class overrides toString() method so when Employee object is printed directly using System.out.println(), it produces nice summary.

This class has been referred by many examples for demonstration purpose.

Want to learn quickly?
Try one of the many quizzes. I promise you will not be disappointed.

About the author



rahimv has over 15 years of experience in designing and developing Java applications. His areas of expertise are J2EE and eCommerce. If you like the website, follow him on Facebook, Twitter or Google Plus.


Your email address will not be published. Required fields are marked *