Although you would have written many constructors before, I am sure you will find some suprises in following facts about constructors. To start with a constructor is nothing but a piece of code of class with same name as that of class which is called whenever an object is created of that class. Now understand following things one by one...
1.If you don't write a constructor for yourself the compiler will insert one - this is call a default constructor. Constructors can have arguments and there can be a no-argument constructor. Compiler inserted constructor will always be a no-arg constructor.
2. Constructors can take any number of arguments, even var-args i.e.: variable arguments. (More on this in a few days.)
3. Constructors cannot be marked final or static or abstract. Because final, static and abstract keywords are for methods, variables and classes. You can consider that constructors implicitly have final kind of behaviour because they are never inherited! They are not methods beware!
4. Constructors cannot have a return type! This is a very important and perhaps the only criteria to recognise quickly whether the given entity is a method or constructor. A method should have return type but a constructor should never have a return type. A method can have same name as that of the class - its perfectly legal! :)
5. Constructors are never inherited! Again...they aren't methods!! You can remember like this - "Constructors are not passed to the younger generation."
6. Whenever a object has to be created then the constructor of that class has to get called and also the constructors of all its super classes should get called. For example if A is parent of B and B is parent of C then to create an object of C we will call C's constructor which in turn will automatically call the constructors of class B and which inturn will call A's constructor and which inturn will call Object's constructor - as by default class A is child of class Object! Remember that the automatically inserted super class constructor call will be always to the no-arg constructor. If you find it a bit difficult then fire your questions in comments.
7. Constructors can use any access modifier. They can use private, protected and public access modifiers. And if nothing is written they have the default one- package level access. Start thinking why anyone would want to make a private constructor! :)
8. Constructors can be over loaded and hence there can be more than one constructors for a single class. A constructor can call other constructor by the keyword this. A call to another constructor with single argument looks like this(i); .A constructor can even explicitly call its super class constructor by keyword super. A call to parent's constructor with no argument looks like super(); . The first statement of every constructor should be a call to this or super.
9. And here's the most stuning one - Abstract classes have constructors! They are called whenever any object of its subclass is created. So the bottom line is every class has a constructor.
10. Interfaces do not have a constructor. An interface is just a contract, a contract to fulfill the implementation of some methods, remember that.
11. You can have call to both this( ) and super( ) in the same constructor. You can have them one inside other, but not both in any single constructor.
Hoossh.. that's all what I can remember right now.. curse my neurotic RAM! If I find anything else I will update the list. If you have any question, then do comment..as you have seen I reply to every question asked.