Programming and Problem Solving with Java

(やまだぃちぅ) #1

730


Chapter 11 Exam Preparation Exercises


  1. a. 1
    b. 2
    c. 7
    d. 7


  2. item first last middle Result
    114 0 9 4
    597
    898 found is true




6.At the logical level, an array is a homogeneous data type. Java implements an array
object with an extra integer variable that contains the number of cells in the array.
9.An iterator/transformer
13.The Comparableinterface has only one method,compareTo, that returns a value less
than 0 if the object comes before the parameter, 0 if the object and the parameter
are equal, and a value greater than 0 if the parameter comes first.


  1. a. If the class allows duplicates and no constraints restrict where the duplicates
    can be placed, then only the deleteoperation needs to be changed. If the
    implementation is sorted, a requirement might state that the duplicate item
    must be placed before or after the last copy inserted. In such a case, the insert
    operation might need to be altered.
    b.There would still be options for the deleteoperation. If there are duplicates,
    does deletemean “delete the first one found,” “delete the last one inserted,” or
    “delete all copies”?


Chapter 11 Programming Warm-Up Exercises
1.public classUnsortedList extendsList
{
publicUnsortedList()
{
super();
}
publicUnsortedList(intmaxItems)
{
super(maxItems);
}
public booleanisThere(String item)
// Return true if item is in the list

T


E


A


M


F


L


Y


Team-Fly®

Free download pdf