Java Reference
In-Depth Information
79
ANSWERS TO SELF-CHECK QUESTIONS
1.
int
and
String
2. Only the first two are legal identifiers.
3.
String myName = ÐJohn Q. PublicÑ
4. No, the left-hand side of the=operator must be a variable.
5.
greeting = ÐHello, Nina!Ñ;
Note that
String greeting = ÐHello, Nina!Ñ;
is not the right answerȌthat statement defines a new variable.
6.
river.length()
or
ÐMississippiÑ.length()
7.
System.out.println(greeting.toUpperCase())
;
8. It is not legal. The variable
river
has type
String
. The
println
method is not a method of the
String
class.
9. The implicit parameter is
river
. There is no explicit parameter. The return
value is 11.
10.
ÐMississi
ss
iÑ
11. 12
12. As
public String toUpperCase()
, with no explicit parameter and
return type
String
.
13.
double
14. An
int
is not an object, and you cannot call a method on it.
15.
(x + y) * 0.5
16.
new Rectangle(90, 90, 20, 20)