AP Computer Science Exam Review - Java Terms

Abstract class

A class that contains one or more abstract methods, and therefore can never be instantiated. Abstract classes are defined so that other classes can extend them and make them concrete by implementing the abstract methods.

Abstract method

A method that has no implementation.

Argument

A data item specified in a method call. An argument can be a literal value or a variable. Example: .get(2); //2 is the argument

Array

A collection of data items, all of the same type, in which each item's position is uniquely designated by an integer.

Block

any code between matching squiggly brackets. Example: { x = 1; }

Boolean

Refers to an expression or variable that can have only a true or false value.

Break

A keyword that exits you out of a loop or switch.

Casting (Type Casting)

Explicit conversion from one data type to another. Example: double var = 3; int ans = (int) var;

Char

a keyword used to declare a variable of type character

Class

defines the implementation of a particular kind of object. A class definition defines instance and class variables and methods, as well as specifying the interfaces the class implements and the immediate superclass of the class. Example:
public class myCl

Class variable (static field)

A data item associated with a particular class as a whole--not with particular instances of the class. Class variables are defined in class definitions.

Compiler

A program to translate source code into code to be executed by a computer. The Java compiler translates source code written in the Java programming language into bytecode for the Java virtual machine.

Continue

A keyword that forces the abrupt end of the current loop iteration and begins another iteration.

constructor

A pseudo-method that creates an object. Constructors are methods with the same name as their class. Constructors are invoked using the new keyword. Example:
public class myClass{
// a constructor that takes one parameter
public myClass(int var){
}
}

Continue

a keyword used to resume program execution at the end of the current loop.

Declaration

A statement that creates a variable of a specific data type. Example: int v;

Default

A keyword optionally used after all "case" conditions in a "switch" statement. If all "case" conditions are not matched by the value of the "switch" variable, the "default" keyword will be executed.

Do

A keyword used to declare a loop that will iterate a block of statements. The loop`s exit condition can be specified with the "while" keyword. A do-while loop is guaranteed to run at least once.

double

A keyword used to define a variable of type double.

else

introduces statements that are executed when the condition in an if statement isn't true.

Exception

An event during program execution that prevents the program from continuing normally; generally, an error.

Extends

Class X extends class Y to add functionality, either by adding fields or methods to class Y, or by overriding methods of class Y. An interface extends another interface by adding methods. Class X is said to be a subclass of class Y.

Field

A data member of a class. Unless specified otherwise, a field is not static.

Final

A keyword that allows you to define an entity once and you cannot change it or derive from it later. More specifically: a final class cannot be subclassed, a final method cannot be overridden and a final variable cannot change from its initialized value.

for

A keyword used to declare a loop that reiterates statements. The programmer can specify the statements to be executed, exit conditions, and initialization variables for the loop.

garbage collection

The automatic detection and freeing of memory that is no longer in use.

if

A keyword used to conduct a conditional test and execute a block of statements if the test evaluates to true.

implements

A keyword optionally included in the class declaration to specify any interfaces that are implemented by the current class.

import

A keyword used at the beginning of a source file that can specify classes or entire packages to be referred to later.

inheritance

The concept of classes automatically containing the variables and methods defined in their superclasses.

initialize

set a variable equal to a specific value. Example: int var = 2;

instance

An object of a particular class. An instance of a class is created using the new operator followed by the class name. Example:
MyClass myObject = new MyClass(/
parameters
/);

instance variable (data member)

Any item of data that is associated with a particular object.

int

A keyword used to define a variable of type integer.

interface

A keyword used to define a collection of method definitions. It can later be implemented by classes that define this interface with the "implements" keyword.

keyword

The Java programming language sets aside words as keywords - these words are reserved by the language itself and therefore are not available as names for variables or methods.

local variable

A data item known within a block, but inaccessible to code outside the block. For example, any variable defined within a method is a local variable and can't be used outside the method.

method

A function defined in a class.

Method header

the line of code that declares a method. Example: public void myMethod( ){
}

new

A keyword used to create an instance of a class

An empty string.

object

The principal building blocks of object-oriented programs. Each object is a programming unit consisting of data (instance variables) and functionality (instance methods).

overloading

Using one identifier to refer to multiple items in the same scope. Basically, it is methods that have the same name, but different parameters. You can overload methods but not variables.

overriding

Providing a different implementation of a method in a subclass of the class that originally defined the method.

Parameter

a variable or object passed into a method. Example:
//var1 and var2 are the parameters
public void myMethod(int var1, double var2){
}

Polymorphism

In a class hierarchy, several methods may have the same name and the same signature, but are in different classes and have different implementation. Assigning multiple meanings to the same method name is called polymorphism.

Primitive

A variable defined with a primitive data type: int, double, char, or boolean.

private

A keyword used in a method or variable declaration. It signifies that the method or variable can only be accessed by other elements of its class. It cannot be accessed outside of the class that defines it.

public

A keyword used in a method or variable declaration. It signifies that the method or variable can be accessed by elements residing in other classes.

Recursion

A method that calls itself.

return

A keyword used to finish the execution of a method. It returns a value after a method executes.

Shadowing

A data member in a subclass that has an identical name to a data member in the superclass. Can also be a method parameter with the same name as a data member in the class. If you do this, the only way to access the data member is use this.variableName.

static

A keyword used to define a variable as a class variable. Classes maintain one copy of class variables regardless of how many instances exist of that class. "static" can also be used to define a method as a class method. Class methods are invoked by the cl

Static Class method

A method that is invoked without reference to a particular object. Class methods affect the class as a whole, not a particular instance of the class.

subclass

A class that is derived from a particular class.

super

A keyword used to access members of a class inherited by the class in which it appears.

superclass

A class from which a particular class is derived.

switch

A keyword used to evaluate a variable that can later be matched with a value specified by the "case" keyword in order to execute a group of statements.

this

A keyword that can be used to represent an instance of the class in which it appears. "this" can be used to access class variables and methods.

variable

An item of data named by an identifier. Each variable has a type, such as int or double, and a scope (where the variable exists).

void

A keyword used in method declarations to specify that the method does not return any value.

while

A keyword used to declare a loop that iterates a block of statements. The loop`s exit condition is specified as part of the while statement.

wrapper

An object that encapsulates and delegates to another object to alter its interface or behavior in some way. (Integer, Double, Boolean)

Naming conventions

o Must start with a lower case letter or underscore
o Cannot contain spaces - camel casing
o Cannot be reserved words
o No punctuation except underscore
o Should be meaningful

Concatenation

Append (adding) strings - link them together

Truncate

dropping a number's fractional part. What happens with integer division