Consider the static method cube() below. How many times is the following for loop iterated? Answer: Just 1,000 times. A call to cube() has no effect on the client code. It changes the value of its...


Consider the static method cube() below.


How many times is the following for loop iterated?


Answer: Just 1,000 times. A call to cube() has no effect on the client code. It changes the value of its local parameter variable i, but that change has no effect on the i in the for loop, which is a different variable. If you replace the call to cube(i) with the statement i = i  * i  *  i; (maybe that was what you were thinking), then the loop is iterated five times, with i taking on the values 0, 1, 2, 9, and 730 at the beginning of the five iterations.



Dec 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here