Question: Supplied code public class ObjectToClone { private static final int NUM_QUARTERS = 4; private int monthDay; private String companyName; private double[] returnValues; private static int

 Supplied code public class ObjectToClone { private static final int NUM_QUARTERS

Supplied code

public class ObjectToClone

{

private static final int NUM_QUARTERS = 4;

private int monthDay;

private String companyName;

private double[] returnValues;

private static int numReports = 0;

public ObjectToClone(String companyName, int monthDay)

{

this.monthDay = monthDay;

this.companyName = companyName;

numReports++;

returnValues = new double[numReports *NUM_QUARTERS ];

for(int i = 0; i

returnValues[i] = Math.random();

}

}

}

Considering the ObjectToClone class below, write a clone method for the class which will return a full deep copy of the object. The return type of your clone method must be ObjectToClone. Your solution must consist of a clone method only (i.e., you should not write any additional constructors or instance methods)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!