Java Reference
In-Depth Information
getWidth
java.lang.String
length
replace
toLowerCase
toUpperCase
javax.swing.JComponent
paintComponent
javax.swing.JFrame
setDefaultCloseOperation
73
74
REVIEW EXERCISES
Exercise R2.1. Explain the difference between an object and an object
reference.
Exercise R2.2. Explain the difference between an object and an object
variable.
Exercise R2.3. Explain the difference between an object and a class.
Exercise R2.4. Give the Java code for constructing an object of class
Rectangle
, and for declaring an object variable of class
Rectangle
.
Exercise R2.5. Explain the difference between the=symbol in Java and in
mathematics.
Exercise R2.6. Uninitialized variables can be a serious problem. Should
you always initialize every
int
or
double
variable with zero? Explain
the advantages and disadvantages of such a strategy.
Exercise R2.7. Give Java code to construct the following objects:
a.
A rectangle with center (100, 100) and all side lengths equal to 50
b.
A string
ÐHello, Dave!Ñ
Create objects, not object variables.
Exercise R2.8. Repeat Exercise R2.7, but now define object variables that
are initialized with the required objects.