No, it is optional . If we do not define a constructor compiler will define a default constructor.
It should not contain Non Access Modifiers:
It can have all four accessibility modifiers:
It can have throws clause:
No, because compiler and JVM considers it as a method.
Only if there is no explicit constructor defined by developer.
By using return type , if there is a return type it is considered as a method else it is considered as constructor.
It is assigned from its class.
If we want do execute some logic at the time of object creation, that logic may be object initialization logic or some other useful logic.
As there is a possibility to define a method with same class name , return type is not allowed to constructor to differentiate constructor block from method block.
Because it obtain all its default properties from its class.
They are:
By using new keyword, if new keyword is used in calling then constructor is executed else method is executed.
Yes, it is allowed to define a method with same class name. No compile time error and no runtime error is raised, but it is not recommended as per coding standards.
No. compiler places default constructor only if there is no explicit constructor.