Exams 2 Preparation

CS 101 & 101-E



Home | Resources | Homeworks | Exams | Slides | Labs | Contacts | Submit | Forums | Private

Test preparation

The exam from last semester is available at available

The quiz from last semester is available at available

Try to solve the following three exercises. The solutions will be considered in lecture on Monday. They will not be considered anywhere else. These exercises will be very similar in nature to actual exam questions, so why not be prepared and practice now.

The Tune class

Give Java definitions for a Tune default constructor and Tune instance method sameArtist(), where Tune is class for representing an audio track. The representation maintains the following four attributes :

Some of the methods provided by the class are as follows:

Some of the other methods provided by the class are attribute accessors and mutators as follows:

Mutators setArtist(), setTitle(), and setAlbum() display an error message if the new value of the attribute is null or represents the empty string "".  Mutators setTime( seconds ), if the modified track time is less than 1 second.

Exercise 1

As a warm-up for the Wednesday test give Java definitions for the Tune default constructor and Tune instance method sameArtist() .

Exercise 2

Give a memory diagram for the following code snippet.

Tune t1 = new Tune();
Tune t2 new Tune( "Neil Young", "I Am the Ocean". "Mirror Ball", 428);

Exercise 3

Update your memory diagram from the second exercise so that it also includes the initial activation record depiction of sameArtist() for the following invocation

t1.sameArtist(t2)