Java Reference
In-Depth Information
A class is a logical abstraction that describes the form and behavior of an object. An
object is a physical instance of the class.
A class is defined by using the keyword
class
. Inside the
class
statement, you specify
the code and data that comprise the class.
Each object of a class has its own copy of the class' instance variables.
class called
MyCounter
.
and has two
int
parameters called
a
and
b
.
A method that returns a value must return via the
return
statement, passing back the
return value in the process.
A constructor has the same name as its class.
The
new
operator allocates memory for an object and initializes it using the object's
constructor.
Garbage collection is the mechanism that recycles unused objects so that their
memory can be reused. An object's
finalize( )
method is called just prior to an object
being recycled.
The
this
keyword is a reference to the object on which a method is invoked. It is
automatically passed to a method.
11
.
Can a constructor have one or more parameters?