CSCI 160 vocabulary
I've sensed some confusion about the vocabulary terms we've met with
in Java, and so I've listed some of the terms we've encountered and
their definitions.
- class
- a custom-defined type in Java.
The libraries include many classes, and all
reasonably sized programs in Java will define several more.
- class method
- a behavior associated with an entire class of objects.
To invoke a class method, you simply name the class, followed by the
method name. A particular instance of the method is not named.
For example, IO.print and Math.pow are both class
methods - to call them, you do not need a IO object to work
with.
Syntactically, Java recognizes a method as a class method whenever its
definition includes the static keyword.
- class variable
- a piece of data associated with an entire class. This is a
piece of memory that is shared between all the instances of
the class, instead of each instance getting its own copy of that
property. Syntactically, Java recognizes a variable declaration as
defining a class variable when it is located inside the class but
outside any methods, and when the declaration includes the
static keyword.
- constructor method
- a method that is invoked only when a new
instance of a class is created. This method typically
simply initializes the instance variables associated with the class.
Syntactically, Java recognizes a method definition as
a class method when it is defined to have no return type and its name is
defined to be the same as the class name in which it is declared.
- declaration
- a Java statement that defines a variable's name and type.
Each variable in Java can only have one declaration.
- instance
- synonymous with object, defined below.
- instance method
- a method specifying a behavior that a particular
object can
have. For example, we might ask an account object to remember that some
money has been deposited into the account. This is something that we
would do to a particular account object, so it would be an instance
method in the Account class, not a class method.
- instance variable
- a variable that is associated permanently with each
particular object of a given class. For example, a
fraction class may have a ``numerator'' instance variable, so that each
fraction object will have its own numerator. An instance variable can be
thought of what each object needs to remember.
- local variable
- a variable that lasts only for the duration of a single
method call.
In Java, any variable declared inside a method is a local variable.
- method
- a named behavior defined in the program. A method may take
parameters, specifying exactly what the method
is to do. It may compute a return value, which is the method's
response to the request. For example, the Double.parseDouble
method takes a String object as a parameter, specifying which
particular String object is to be parsed. The method returns an
double holding the double value represented in the string.
- object
- A particular ``thing'' created to represent some concept.
Most often, an object will be a conglomeration of several other pieces
of data.
For example, you might have an object to represent a fraction, which is
a conglomeration of two integer values representing a numerator and a
denominator.
- parameter
- a value given to a method to further specify what the method is to
do. For example, the IO.print method takes a parameter that
specifies what the method is to print. And the Math.pow method
takes two double parameters specifying first the base of the
exponent and then the exponent. Each method contains local variables so
that within the method they can refer to the values of the variables.
- primitive type
- the eight types boolean, char, byte,
short, int, long, float, and
double that are built directly into the Java language.
Values of these types are not objects; instead, they're stored directly
in a variable as a sequence of bits.
- package
- a set of associated classes. In Java, they are associated
by simply being located in the same directory. The Java libraries are
broken up into smaller packages for various purposes. The
java.io package, for example, contains all the classes having
to do with input and output.
- variable
- a named location in memory where data of a particular type is
stored.