CS 2401 Quiz #1

Date: Monday, August 22, 2011.

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

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







2. Write down a piece of code to print out the first 5 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 smallest element of an array of doubles. Trace your code on an example array consisting of the numbers 3.2, 1.4, and 4.6.