Free University of Bozen-Bolzano
Faculty of Computer Science - Bachelor in Applied Computer Science
Introduction to Programming - A.A. 2005/2006
(old study plan - 6 CFU)

Written Exam 14/6/2006

We want to design a Java class for representing and manipulating lists of birthdays of persons.

Part 1. (4 points) For each Birthday object, the information of interest is:

Realize a Java class Birthday, to represent Birthday objects, that exports the following functionalities:

Part 2. (16 points) Realize a Java class BirthdayList, to represent BirthdayList objects. Each birthday list is constituted by a sequence of birthdays, where each birthday is an instance of the class Birthday. A BirthdayList has also a size, which determines the maximum number of birthdays it can contain. The class BirthdayList should export the following functionalities:

Part 3. (6 points) Realize a static method personsWithBirthday, client of the class BirthdayList (i.e., external to such a class) that, given a BirthdayList object bl, a day d (an integer), a month m (an integer), and the name f of a file, writes on the file f the names of all those persons in the list whose birthday is on day d and month m, one name per line. The method should explicitly handle exceptions due to input/output errors that may occur.

Part 4. (4 points) Discuss the mechanism of dealing with errors in Java through exceptions. Give a complete example, where you show how a class for handling exceptions is defined, how an exception is thrown, and how an exception is handled by catching it.