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

Written Exam 30/1/2007

A library maintains books on various subjects.

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

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

Part 2. (16 points) For each topic (identified by its name, a string), the books on that topic available in the library shop are stored in a BookList data structure. Each book in a BookList is assigned a progressive number (an integer), starting from 0. A BookList has a size, which determines the maximum number of books it can contain.

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

Part 3. (6 points) Realize a static method writeBooksByAuthor, client of the class BookList (i.e., external to such a class) that, given a BookList object bl, a string s (representing the name of an author), and the name f of a file, writes on the file f the title and authors of all those books in bl for which s appears among the authors, one book per line. The method should catch exceptions due to input/output errors that may occur, and print suitable error messages.

Part 4. (4 points) Discuss the notion of parameter passing in Java. Illustrate the difference between passing parameters of type (reference to an) object and of primitive types. Provide an example in which this difference becomes evident.