Java - Things to know before your OCJP Exam - Constructor

1. Constructors can be overloaded.

2. * Constructors shouldn't have any return types , not even void.

3. * Default constructor is provided by the compiler if we don't declare any constructor. If we declare a parameterized constructor, Compiler will not create any default non parameterized constructor for the class.



4. A constructor can only have either this or super statement and that statement should be the first statement in constructor.



5. If Constructor has been declared private, Objects of the class cannot be instantiated from outside class.



6. If super is not explicitly called, still super() is intrinsically added by the compiler.



7. * Default Constructor initializes the instance variables to their default values.



8. * Final variables can be initialized within constructor.