Free University of Bozen-Bolzano
Bachelor in Production Engineering
Introduction to Programming - A.A. 2006/2007

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, and a string s (representing the name of an author), writes to standard output the title, publisher, and year of all those books in bl with author s, one book per line.

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.