Java Reference
In-Depth Information
can gain access to the hidden instance variable by referring to it through
this
. For example,
the following is a syntactically valid way to write the
Pwr( )
constructor.
In this version, the names of the parameters are the same as the names of the instance vari-
ables, thus hiding them. However,
this
is used to “uncover” the instance variables.
Chapter 4 Self Test
class called
MyCounter
.
and has two
int
parameters called
a
and
b
.
11
.
Can a constructor have one or more parameters?