CS 2401 Quiz #1

Date: Tuesday, August 23, 2011.

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

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







2. Write down a piece of code to print out the first 4 natural numbers (counting numbers) on a separate line, followed by the sum of these numbers on a separate line.














3. Write down a piece of code for computing the largest element of an array of doubles. Trace your code on an example array consisting of the numbers 2.5, 5.75, and 3.1.