CS 1401, Quiz #12

Date: Tuesday, April 19, 2005
Section: (starting 9 am or starting 10:30 am) ______________________________________________________________________

Name (please type legibly, ideally in block letters): ______________________________________________________________________

1. Write a method that, given an array of integers, returns the average of all the numbers from this array (i.e., their sum divided by their number).

Trace this method on an array with two elements 2 and 3; the average should be 2.5.

For extra credit: what happens if you define an array numbers consisting of only two elements numbers[0] and numbers[1], and your method tries to access the element numbers[2]?