This exercise demonstrates using a reference parameter to pass data back to the argument supplied in the

Question:

This exercise demonstrates using a reference parameter to pass data back to the argument supplied in the method call. Suppose you want a Car5 class to include a method with this heading: public int copyTo(Car5 newCar) This method is supposed to be called by an existing Car5 object with another Car5 object as the argument. When any instance variable of the calling car has been initialized and the corresponding variable of the parameter car has not been initialized, the method should assign that calling- car variable value to the corresponding parameter-car variable and increment a counter that keeps track of the number of features copied. After trying to copy each of the calling car’s instance variable values, the method should return the total number values copied. Here’s a driver that illustrates the usage:

* Car5Driver.java *Dean & Dean * * This class exercises the Car5 class. public class Car5Driver { public

Write the code for the desired copyTo method.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: