- A constructor has to be called directly when ...
Never.
You invoke a constructor by using the new key word and the JVM will invoke the constructor for you.
- Constructor overloading will be done when ...
You write brittle code.
Constructor overloading means that you have more than one constructor in the same class.
Constructors should set (final) instance variables (aka members or fields) of the object (and nothing else except simple validations). Since different constructors must have different parameter types or different parameter count the consequence of having them is one of four cases:
You only set the the members having relates parameters passed in into the individual ctor.
The result of this is that you have to assign
nullto members not relating to a parameter of the current ctor. This usually means that you have an invalid object forcing you to throw null-checks throughout your code.You assign some default values to members not relating to a parameter of the current ctor or call another ctor in this class passing the current parameters and those default values. (constructor chaining)
The consequence of this is that you hide the real dependencies of your class from the user. Users of your class may be confused.
You "calculate" the missing values.
Ctors should not do any calculation, just initializing the members. Anything else will make your class hard to reuse.
You acquire missing values by accessing static methods in other classes (singeltons by any chance...)
This is the worst case since it creates an unbreakable hidden coupling to this other (singeton) class.
As a rule of thumb: A class should have one ctor only.
- Methods will be called directly by calling the default constructor when ...
Never.
A constructor (as already written) only assigns values to members. It does not calculate anything and therefore it should not call any other method within the class.
As you become experienced you might find valid reasons to brake these rules, but as a beginner you should stick to them.