Exams 2 Preparation
CS 101 & 101-E
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.
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:
- public String getArtist()
- public String getTitle()
- public String getAlbum()
- public String getTime()
- public String setArtist( String performer )
- public String setTitle( String name )
- public String setAlbum( String compilation)
- public String setTime( int seconds )
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.
As a warm-up for the Wednesday test give Java definitions for the Tune default constructor and Tune instance method sameArtist() .
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);
Update your memory diagram from the second exercise so that it also includes the initial activation record depiction of sameArtist() for the following invocation