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:
Write the code for the desired copyTo method.
Step by Step Answer:
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean