ZyBooks COS 160 USM Final
escape sequence
- a series of characters that represents a special character - begins with a backslash character (/)
Bytecode interpreter
- a software tool that translates bytecode into machine language and executes it - a.k.a. "Just-in-time compiler"
compile-time errors
- syntax errors and other basic problems - if these exist, an executable version of the program is not created (there will be no .class file)
unary minus
- used as negative
string concatenation operator (+)
- used to append one string to the end of another -it can also be used to append a number to a string
What are the three types of errors that a program can have?
1) Compile-time errors 2) Run-time errors 3) Logical errors
What does the Java compiler do?
The Java compiler translates Java source code into a special representation called bytecode.
block
a brace-enclosed {...} sequence of statements , such as found with an if-else, for loop, or while loop
InputStream
a class that supports input provides several overloaded
OutputStream
a class that supports output provides several overloaded methods for writing a sequence of bytes to a destination. That sequence is normally placed into a buffer, and the system then outputs a buffer at various times
interface
a class' public member methods
expression
a combination of items, like variables, literals, and operators, that evaluates to a value
loop
a construct that repeatedly executes specific code as long as some condition is true
default constructor
a constructor that can be called without any arguments
type conversion
a conversion of one data type to another (such as an int to a double)
abstract data type (ADT)
a data type whose creation and update are constrained to specific well-defined operations
exception
a detected runtime error that commonly prints an error message and terminates the program
block (a.k.a. block statement)
a list of statements surrounded by braces
method
a list of statements that can be executed by referring to the method's name
nested loop
a loop that appears in the body of another loop
infinite loop
a loop that will always execute (i.e., execute infinitely) because the loop's expression always evaluates to true
member method
a method that is a part of (a "member of") a class
identifier
a name created by a programmer for an item like a variable or method (must be a sequence of letters (a-z, A-Z, _ , $) and digits (0-9) and must start with a letter)
method
a named list of statements
floating-point literal
a number with a fractional part (even if the fraction is 0, as in 1.0 or 0.0)
System.out
a predefined output stream object reference that is associated with a system's standard output automatically reads the standard input from a memory region, known as a buffer, that the operating system fills with the input data
while loop
a program construct that executes a list of sub-statements repeatedly as long as the loop's expression evaluates to true
boolean
a quantity that has only two possible values, true or false
scope
a region of code were a declared name is valid
testbench (a.k.a. test harness)
a separate program whose sole purpose is to check that a method returns correct output values or a variety of input values
string
a sequence of characters
compiler
a software tool which translates source code into a specific target language
constructor
a special class member method that is called automatically when a variable of that class is allocated, and which can be used to initialize all fields has the same name as the class has no return type (not even void)
literal
a specific value in code (like 2)
break statement
a statement in a loop that causes an immediate exit of the loop
continue statement
a statement in a loop that causes an immediate jump to the loop condition check
operator
a symbol for a built-in language operation
javadoc
a tool that parses specially formatted multi-line comments to generate program documentation in HTML format
escape sequence
a two-character sequence starting with \ that represents a special character (Ex. '\n' represents a newline character)
field (a.k.a. class member)
a variable declared within a class but outside any method
reference variable (a.k.a. reference type)
a variable of class type
call by value
a variable of primitive type (like int or char) is passed to a method by passing the value of the variable the argument value is copied into a local variable for the parameter
char
a variable of this type can store a single character (like the letter m or the symbol %)
double
a variable of this type stores a floating-point number
reserved word (keyword)
a word that is part of the language, like int, short, or double
logical errors
happens when a program runs, but produces incorrect results, perhaps from using an incorrect comparison or formula
method call
invokes a method's name and causes the method's statements to execute
method call
invoking a method
public
members of a class that are declared with this visibility can be referenced anywhere
private
members of a class that are declared with this visibility can be referenced only within that class
method stubs
method definitions whose statements haven't been written yet
overflow
occurs when the value being assigned to a variable is greater than the maximum value the variable can store
run-time errors
problems that occur during execution, such as trying to divide by zero, which causes a program to terminate abnormally
compound operators
provide a shorthand way to update a variable (E.g. +=, -=, /=, %=)
parameter
provides input to a method influences method behavior like a variable declaration; indicates the type followed by the parameter name
IOException
provides mechanisms for exception throwing and handling
braces {} (a.k.a. curly braces)
represent a grouping, such as a grouping of statements
collection
represents a generic group of objects known as elements
variable
represents a memory location used to store data
regression testing
runs an existing testbench whenever code is changed checks to see whether the change caused code to "regress", meaning to fail previously-passed test cases
short circuit evaluation
skips evaluating later operands if the result of the logical operator can already be determined
assignment statement
stores (i.e. assigns) the right-side item's current value into the variable on the left side
throws clause
tells the Java Virtual Machine that the corresponding method may exit unexpectedly due to an exception
border cases
testing fringe scenarios to see if the program fails
member access operator
the "." operator, which a member-method call uses
scope
the part of the program where the name of a defined variable or method item is visible starts after the declaration until the method's end
debugging (a.k.a. troubleshooting)
the process of determining and fixing the cause of a problem in a computer program
unit testing
the process of individually testing a small part or unit of a program, typically a method
loop body
the sub-statements inside the braces of a while loop
argument
the value passed to a parameter an expression (such as 99, numCars, or numCars + 99)
PrintStream
this class extends the base functionality of the OutputStream class and provides the print() and println() methods for converting different types of data into a sequence of characters
class
this construct defines a new type that can group data and methods to form an object
accessor (a.k.a. getter)
this method accesses fields but may not modify them
return
this method causes execution to jump back to the original calling location
mutator (a.k.a. setter)
this method may modify ("mutate") the class' fields
new
this operator is used to explicitly allocate an object
void
this return type indicates that a method does not return any value
switch statement
this statement can more clearly represent multi-branch behavior involving a variable being compared to constant values The program executes the first case whose constant expression matches the value of the switch expression, executes that case's statements, and then jumps to the end. If no case matches, then the default case statements are executed.
logical operator
treats operands as being true or false, and evaluates to true or false
method name overloading
when a program has multiple methods with the name name but differing in the number or types of parameters
type casting
when a programmer precedes an expression with "(type) expression" to convert the expression's value to the indicated type
code coverage
when all code is executed at least once
row-major order
when each row follows the previous row
array
an ordered list of items of a given data type
Arraylist
an ordered list of reference type items
reference type variable
can refer to an instance of a class, also known as an object
for loop statement
collects three parts - the loop variable initialization, loop expression, and loop variable update- all at the top of the loop
assert statement
commonly used to check for correct execution
conditional expression form
condition ? expreWhenTrue : expreWhenFalse
object
consists of some internal data items plus operations that can be performed on that data
method definition
consists of the new method's name and block of statements
stack frame
corresponds to a call to a subroutine which has not yet terminated with a return contains: 1) method parameters 2) return address 3) local variables
loop variable
counts the number of iterations of a loop
enumerator type
declares a name for a new type and possible values for that type
primitive type variable
directly stores the data for that variable type, such as int, double, or char
branching
directs a program to execute either one statement group or another, depending on an expression's value
iteration
each execution of the loop body of a while loop
element
each item in an array
test vector
each unique set of input values in a testbench
primitive wrapper classes
allow the program to create objects that store a single primitive type value, such as an integer or floating-point value provide methods for converting between primitive types, between number systems, and between a primitive type and a String representation
FileInputStream
allows a programmer to read bytes from a file
call by reference
an array is passed to a method by passing a reference to the array the array reference is copied to the method's parameter, so a method can modify the elements of an array argument
exception
an event that disrupts a program's execution
constant variable (final variable)
an initialized variable whose value cannot change
argument
an input value to a method that appears between parentheses