Carl Reynolds and Paul Tymann
"Schaum's Outline of Principles of Computer Science"
We say that
???is??? . Some writers say that an ???is-a??? relationship exists between
an instance and its class. For instance, my Ford is an Automobile.
OBJECT STATE AND BEHAVIOR
Grady Booch, a well-known writer on the topic of OO programming, has defined an object as
something ???that has state, behavior, and identity.??? In other words, an object has characteristics (which may
change over time), an object can perform certain prespecified actions, and an object provides us a way to
refer to it.
78 PROGRAMMING IN JAVA [CHAP. 5
The state of an object is provided by variables. As the values of variables change, the state of the object
changes. At any point in time, the values of the instance??™s variables provide its state. For example, the speed
of my Ford varies over time. At any particular moment, the state of my Ford includes the speed at which it is
currently moving.
The behavior of objects is provided by methods. A method is a programming procedure. In the case of my
Ford, the accelerate() method allows my Ford to change speed. In the world around us, we observe that
different members of the same class behave similarly; it??™s easy to distinguish a dog from a cat by the way the
individual animals move.
Pages:
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217