Java Reference
In-Depth Information
c. The change in the text position results in a run-time error—
“Bottom” is not a valid argument for the setHorizontalTextPo-
sition method.
d. Since you changed the vertical position of the text within the label,
the text “Devil Above” appears directly on the third image.
Chapter 4 Writing Classes
4.1 Classes and Objects Revisited
SR 4.1
An attribute is a data value stored in an object and defines a par-
ticular characteristic of that object. For example, one attribute of a
Student object might be that student's current grade point average.
Collectively, the values of an object's attributes determine that object's
current state.
SR 4.2
An operation is a function that can be done to or done by an object. For
example, one operation of a Student object might be to compute that
student's current grade point average. Collectively, an object's opera-
tions are referred to as the object's behaviors.
SR 4.3
Some attributes and operations that might be defined for a class called
Book that represents a book in a library are:
Attributes
Operations
idNumber
checkOut
onShelfStatus
checkIn
readingLevel
isAvailable
dueDate
placeOnHold
setStatus
SR 4.4
The answers are:
a. False - Identifying classes to help us solve a problem is a key step
in object-oriented programming. In addition to identifying classes
that already exist, we also identify, design, and implement new
classes, as needed.
b. True - We call such operations mutators.
c. True - The result of many operations depends on the current state
of the object on which they are operating.
d. False - In Java, the state of an object is represented by its instance
data.
Search WWH ::




Custom Search