Java Glossary
Java Glossary
abstract
keyword for a method that has no body, and instead specifies a return type and a formal
parameter list. An abstract method must be inside a class that is declared to be abstract.
Instantiation is deferred to a subclass that implements the abstract method.
args
The conventional name of the String array for command-line arguments. If your program
takes command-line args, args[0] references the first string. For example, java HelloWorld
Thomas could print Hello Thomas.
array
a collection of items of the same type, such as an int array. Two ways to create an array are:
boolean
primitive data type that can have the value true or false, but cannot be cast to a String,
char, or int.
break
keyword for a branching command that is typically used to exit a loop. The loop condition
can then be reevaluated.
case
see switch
catch
keyword to introduce the block of code that handles an Exception
char
a primitive type that can contain a single character. Example: char myChar = 'a';
checked exception
an exception that is not of type RuntimeException, such as IOException. The compiler
requires that a class that can throw a checked exception explicitly declare the exception it
might throw. For example,
class FileCopier throws IOException
class
a template for creating objects
constructor
a member of a class that has parentheses like a method, but does NOT have return type
and its name must match the name of the class for which it is a member. A constructor is
used with the new operator to create an instance of a class. The synatax
is: new Constructor();
continue
keyword for a branching command that is typically used to immediate execute the next
iteration of a loop without executing any remaining statements in the loop.
double
floating point type that the JVM uses internally by default
else
keyword for the catch-all clause in an if, else if, else ladder
encapsulation
feature of object-oriented programming that recommends a class enclose all the data (field)
and behavior (methods) of that class. For example, the Automobile class would not have
fields and methods that belong to the Bicycle class, such as a cadence field, which
represents how fast the feet move in a circle to make the bicycle move.
extends
keyword to declare a subclass
field
a member of class that represents data. It can be an instance variable or a static variable.
final
keyword that makes a variable value constant
for
a for loop has the following syntax:
for(initialization; condition; increment)
{
// do something
}
for each
formal parameter
In the definition of a constructor or method, the formal parameter is a placeholder for the
runtime argument.
For example,
getBalance(int accountId) { ... }
if
keyword for the branching statement that evaluates a boolean condition, and executes the
following statement when the condition is true
implements
keyword in a class declaration that indicates that this class is governed by an interface. For
example,
class Toy implements ITaxable
import
keyword at the top of a .java file that tells the compiler which package and classes the file
uses. For example,
import java.util.*;
means that your code can use Scanner myScanner;
instead of java.util.Scanner myScanner;
inheritance
feature of object-oriented programming that allows maximum code reuse by allowing a
subclass to receive the functionality of its superclass
instanceof
operator that tests whether an object is of a specific class or not. For example,
if(myName instanceOf String)
instance variable
a field. An object is an instance of a class, and each instance has a copy of the fields of that
class. Those fields are also called instance variables. For example, a car object might have
an instance variable named price
int
primitive type for whole numbers
interface
a template for creating classes
members of a class
fields, constructors, methods
method
the member of a class that defines and executes a behavior or operation. A method looks
similar to a constructor insofar as it has parentheses, but unlike a constructor, a method has
a return type, and a method name should be:
new
The operator that allocates memory in the JVM for an object. The synatax
is: new Constructor();
object
an instance of a class
OOP
object-oriented programming, which models the real world, unlike procedural programming
in language like C
package
keyword to declare a logical grouping of related classes.
polymorphism
feature of object-oriented programming that allows the name of methods and constructors
to be overloaded. For example,
primitive
A primitive data type – such as boolean, int, double, char – has no methods and operates
faster than a reference type, such as String.
public
keyword that expands the visibility of a field or method beyond the current package.
private
keyword that reduces the visibility of a field or method to the current class.
JVM
Java Virtual Machine is a process that executes Java bytecode, such that it simulates a
computer (or operating system) running on top of the host machine. The JVM has automatic
memory management though its "garbage collector".
interpreter
Within the JVM, the interpreter converts bytecode to the native machine code.
recursive method
A method that calls itself, each time moving toward a terminal case so that no infinite loop
occurs.
return
keyword for the command that forces execute to exit a method and return to the method
that called the current methods with the "return" keyword. If the method is not void, both
execution and a value is returned to the caller.
runtime argument
a value passed to a call to a constructor or a method. The type of the value must match
for formal parameter in the definition.
String
a reference type for multiple characters
static
keyword that indicates a field or method exists in memory without have to create an
instance of the class for which it is a member
super
keyword to the immediate superclass field, as in super.myInt. For a constructor, super().
For a method, super.methodName().
switch
a switch control is an alternative to the if, else if, else ladder that requires all the
conditional tests to depend upon a series of case statements about a single variable. Also,
instead of the catch-all keyword being else, it is default.
this
keyword that refers to the newly-created object of the current class. Can be used to
reference the constructor as this(), a field as this.myInt, or a method as this.doSomething().
throw
keyword that causes the JVM to create an instance of the specified Exception
throws
keyword in a class declaration for a checked Exception that indicates this class can throw an
instance of the specified Exception
token
what the Java compiler looks for to process source code. A token can express an identifier,
such as a variable name, a Java keyword, a separator (such as white space), an operator, a
literal, or a comment.
try
keyword for the block of code that might cause the JVM to throw an Exception
void
keyword for method return type that returns no value
while
keyword for a loop type that is equivalent to a for loop, but which separates into three
separate statements the counter initialization, conditional test, and counter increment
variable
a named place in memory. For example, the varable myInt in int myInt = 3; allows the
programmer to have a reusable handle to that value. such that the value can be referenced
to read it or reassign its value.