Computer Applications
Distinguish between parameterised constructor and non-parameterised constructor.
Java Constructors
18 Likes
Answer
Parameterised constructor | Non-parameterised constructor |
---|---|
It initialises the instance variables with the help of parametric values passed at the time of creating an object. | It initialises the instance variables of an object with definite values readily available within it. |
It is defined with formal parameters in its parameter list. | It is defined with empty parameter list. |
For example, Test(int x, int y) { a = x; b = y; } | For example, Test() { a = 10; b = 5; } |
Answered By
10 Likes