Java Reference
In-Depth Information
in part because the concepts are inherently difficult. A number of Web sites are
available that discuss design patterns, and which provide study guides for the De-
sign Patterns topic. Two other topics that discuss object-oriented software design
are Object-Oriented Software Design and Construction withC ++ by Dennis Ka-
fura [Kaf98], and Object-Oriented Design Heuristics by Arthur J. Riel [Rie96].
1.6
Exercises
The exercises for this chapter are different from those in the rest of the topic. Most
of these exercises are answered in the following chapters. However, you should
not look up the answers in other parts of the topic. These exercises are intended to
make you think about some of the issues to be covered later on. Answer them to
the best of your ability with your current knowledge.
1.1 Think of a program you have used that is unacceptably slow. Identify the spe-
cific operations that make the program slow. Identify other basic operations
that the program performs quickly enough.
1.2 Most programming languages have a built-in integer data type. Normally
this representation has a fixed size, thus placing a limit on how large a value
can be stored in an integer variable. Describe a representation for integers
that has no size restriction (other than the limits of the computer's available
main memory), and thus no practical limit on how large an integer can be
stored. Briefly show how your representation can be used to implement the
operations of addition, multiplication, and exponentiation.
1.3 Define an ADT for character strings. Your ADT should consist of typical
functions that can be performed on strings, with each function defined in
terms of its input and output. Then define two different physical representa-
tions for strings.
1.4 Define an ADT for a list of integers. First, decide what functionality your
ADT should provide. Example 1.4 should give you some ideas. Then, spec-
ify your ADT in Java in the form of an abstract class declaration, showing
the functions, their parameters, and their return types.
1.5 Briefly describe how integer variables are typically represented on a com-
puter. (Look up one's complement and two's complement arithmetic in an
introductory computer science textbook if you are not familiar with these.)
Why does this representation for integers qualify as a data structure as de-
fined in Section 1.2?
1.6 Define an ADT for a two-dimensional array of integers. Specify precisely
the basic operations that can be performed on such arrays. Next, imagine an
application that stores an array with 1000 rows and 1000 columns, where less
Search WWH ::




Custom Search