Default Constructors (by Mala Gupta, Author of "OCA Java SE 7 Programmer I Certification Guide") Blog

Version 2

    Constructors are special methods defined in a class that create and return an object of the class in which they're defined. Constructors have the same name as the name of a class and they don't specify a return type, not even a void. Constructors come in two flavors: user-defined constructors and default constructors. In this article, based on chapter 3 of OCA Java SE 7 Programmer I Certification Guide, author Mala Gupta discusses default constructors.

    As you may know, a constructor is used to create an object. What happens if you don't define any constructor in a class? The following is an example of class Employee that doesn't define a constructor:

    class Employee {