1) CC one = new CC();
The call will go to Line 1
As here a object as been created with no parameters hence call will go to non-parameterized constructor
2) CC two = new CC(5,6)
The call will go to Line 3
Here the object is created with two parameters so the call will go to parameterized constructor with two arguments.
3) CC three = new CC(2,8,3.5)
The call will go to Line4
Here the object is created with three parameters now we have two constructor defined with three parameters one at line 4 and another at line5 but the call will go to line 4 because the passed arguments value matches with data type of parameters at line 4, i.e. int , int ,double ( here 2 is int , 8 is int and 3.5 is double).
4) The definition will as below
public CC()
{
u=0;
v=0;
w=0.0
}
Comments
Leave a comment