Self-Assessment Exercises
Chapter 4:
Inside Class Methods
1.
In Java, the statement
x = 7
means that the variable
x
is ________.
a.
equal to 7
b.
actually a constant with the value 7
c.
assigned the value 7
d.
tested to see if its value is 7
2.
The ________ of the variable tells you where it is visible or, in other terms, how long the variable holds onto its value.
a.
declaration
b.
position
c.
scope
d.
type
3.
The value of the Java expression
99 / 100
is ________.
a.
0
b.
1
c.
0.99
d.
99%
4.
The expression
variableA + variableB
can be used to ________.
a.
add the values of two integer variables
b.
add the values of any two numerical variables
c.
concatenate the values of two
String
variables
d.
All of the above
5.
The statement
x += 2;
is equivalent to ________.
a.
x = x + 2;
b.
x = x + 1 = x + 1;
c.
++x;
d.
x++;