Default constructor vs Parametrized constructor: In this article, we will list the difference between the default constructor and parameterized constructor in Java. Let us detail out the difference between the Default constructor v/s Parametrized constructor in the tabular form below.
Default Constructor vs Parametrized Constructor
Default constructor | Parameterized constructor |
A constructor which takes no arguments is known as the default constructor | A constructor which takes one or more arguments is known as parameterized constructor |
The compiler inserts a default no-arg constructor after compilation if there is no explicit constructor defined in a class | When the parameterized constructor is defined in a class, then the programmer needs to define default no-arg constructor explicitly if required |
No need to pass any parameters while constructing new objects using the default constructor | At least one or more parameters need to be passed while constructing new objects using argument constructors |
A default constructor is used for initializing objects with the same data | Whereas parametrized constructor is used to create distinct objects with different data |
Example for Default constructor vs Parametrized constructor
Read Also: Difference Between Final Finally and Finalize
Employee.java
Leave a Reply