Advertisements
Advertisements
Question
Differentiate between the following statements:
abc p = new abc();
abc p = new abc(5,7,9);
Distinguish Between
Advertisements
Solution
| S.No. | abc p = new abc(); | abc p = new abc(5,7,9); |
| 1. | As illustrated below, the statement abc p=new abc() calls the default constructor. | The statement abc p=new abc(5,7,9) calls the parameterised constructor (seen below). The numbers 5, 7, and 9 are copied to formal parameters x, y, and z, which are used for setting the class's instance variables. |
| 2. |
|
|
shaalaa.com
Is there an error in this question or solution?
