Java Reference
In-Depth Information
Class
Attributes
Operations
Set address
Set major
Compute grade point average
Student
Name
Address
Major
Grade point average
Rectangle
Length
Width
Color
Set length
Set width
Set color
Aquarium
Material
Length
Width
Height
Set material
Set length
Set width
Set height
Compute volume
Compute filled weight
Flight
Airline
Flight number
Origin city
Destination city
Current status
Set airline
Set flight number
Determine status
Employee
Name
Department
Title
Salary
Set department
Set title
Set salary
Compute wages
Compute bonus
Compute taxes
FIGURE 4.1 Examples of classes and some possible attributes and operations
SELF-REVIEW QUESTIONS (see answers in Appendix N)
SR 4.1
What is an attribute?
SR 4.2
What is an operation?
SR 4.3
List some attributes and operations that might be defined for a class
called Book that represents a book in a library.
SR 4.4
True or False? Explain.
a. We should use only classes from the Java standard class library
when writing our programs—there is no need to define or use
other classes.
b. An operation on an object can change the state of an object.
c. The current state of an object can affect the result of an operation
on that object.
d. In Java, the state of an object is represented by its methods.
 
 
Search WWH ::




Custom Search