
If we do not define any constructor in a class, JVM automatically inserts a default constructor with an empty body. I have read some question here but they don't address this. A constructor with one or more parameters is called as parameterized constructor. Inside the constructor, we can access all object attributes and assign them to their default or desired values. I also notice that the fields inside the no param constructor can be changed using getter and setter methods, so I do not see differences with a constructor that has parameters. I have written the class to get a better understanding. If we define only parameterized constructors, then we cannot create an object. Based on that information and their example. Parameterized constructors are required to pass parameters on creation of objects. Parameterized Constructor in Java A constructor that has parameters is known as parameterized constructor. Parameterized constructor I will explain in one Example. The default constructor's job is to call the super class constructor and initialize all instance variables. Calling a constructor from another constructor in Java is primarily a means of providing default values for parameters to the one constructor that should actually construct your object, and then it should be enough to just assign values in the constructors body.


It is essentially a non-parameterized constructor, i.e. From the java tutorial I see that a class can have two different constructors with the distinction being the number of arguments provided in each constructor, they also give an example of the no constructor parameter. When we do not explicitly define a constructor for a class, then java creates a default constructor for the class.
