CS 2401 Quiz #1

Date: Tuesday, January 25, 2011.

1. What will be the printed as a result of the following code:

  int [] a = {1, 2, 3};
  int [] b = new int [3];
  b = a;
  b[0]++;
  System.out.println(a[0]);
Explain your answer

2. Last year, our college had a team competition about who walks the most. Volunteers were issued pedometers, and their readings were recorded. Let us assume that the number of miles walked by each team is given in an array m[i]. Write down a piece of code for finding the wining team. Trace this code on the example of an array consisting of numbers 450, 520, and 480.