[an error occurred while processing this directive]
CIS 110

Recitation 2 Exercises (19/20 September 2012)

Before each recitation we will post a short set of written exercises. These are intended to help you prepare for recitation. You must complete them to the best of your ability, and bring them to recitation. Your TAs will note whether you have completed them along with your attendance. These exercises will not be graded for correctness, but you must attempt to answer them and bring your answers to recitation. A portion of your grade depends on your attempting these exercises each week and attending recitation.

We will talk about functions in lecture on Wednesday. If you don't understand the questions, wait until after lecture to work on them.

Question 1 Consider the static method cube() below:

public static void cube(int i) {
    i = i * i * i;
}
How many times is the following for loop iterated?
for (int i = 0; i < 1000; i++)
    cube(i);





Question 2 Write a static method odd() that takes three boolean inputs and returns true if an odd number of inputs are true, and false otherwise.