Consider the definition of the following class: public class CC { private int u; private int v; private double w; public CC( ) //Line 1 {…} public CC(int a) //Line 2 {…} public CC(int a, int b) //Line 3 {…} public CC(int a, int b, double d) //Line 4 {…} A. Give the line number containing the constructor that is executed in each of the following declarations: (i) CC one = new CC( ); _________________ (ii) CC two = new CC(5, 6); _________________ (iii) CC three = new CC(2, 8, 3.5); _________________ B. Write the definition of the constructor in Line 1 so that the instance variables are initialized to 0. C.Write the definition of the constructor in Line 4 so that the instance variables u, v, and w are initialized according to the values of the parameters a, b, and d, respectively.
- Consider the definition of the following class:
public class CC
{
private int u;
private int v;
private double w;
public CC( ) //Line 1
{…}
public CC(int a) //Line 2
{…}
public CC(int a, int b) //Line 3
{…}
public CC(int a, int b, double d) //Line 4
{…}
A. Give the line number containing the constructor that is executed in each of the following declarations:
(i) CC one = new CC( ); _________________
(ii) CC two = new CC(5, 6); _________________
(iii) CC three = new CC(2, 8, 3.5); _________________
B. Write the definition of the constructor in Line 1 so that the instance variables are
initialized to 0.
C.Write the definition of the constructor in Line 4 so that the instance variables u, v, and w are initialized according to the values of the parameters a, b, and d, respectively.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps