jump to navigation

Constructor June 18, 2007

Posted by Allu in JAVA.

The automatic initialization is performed through the constructor, constructor has same name has class name. Constructor has no return type not even void. We can pass the parameters to the constructor. this() is used to invoke a constructor of the same class. Super() is used to invoke a super class constructor. Constructor is called immediately after the object is created before the new operator completes.

 Constructor can use the access modifiers public, protected, private or have no access modifier

 Constructor can not use the modifiers abstract, static, final, native, synchronized or strictfp

 Constructor can be overloaded, we cannot override.

 You cannot use this() and Super() in the same constructor.