IS Data Structures & Java 4415 Quiz 2

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

formal parameter

A parameter is like a placeholder: when a method is invoked, you pass a value to the parameter. This value is referred to as an actual parameter or parameters

method signature

The method name and the parameter list together.

operator precedence

The order in which operators are evaluated in a numeric expression.

loop body

The part of the loop that contains the statements to be repeated.

Boolean value

True or False

scope of variable

the part of the program where the variable can be referenced

escape character

A character in text that is not taken literally but has a special meaning when combined with the character or characters that follow it. The \ character is an escape character in Java strings.

method

A collection of statements grouped together to perform an operation. You can create your own but this also includes predefined methods such as System.out.println, System.exit, Math.pow, and Math.random.

sentinel value

A common technique for controlling a loop is to designate a special value when reading and processing a set of values. This special input value

Flowchart

A diagram that describes an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting these with arrows.

posttest loop

A loop whose condition is evaluated after the instructions in its loop body are processed. This is for do while loops

pretest loop

A loop whose condition is evaluated before the instructions in its loop body are processed. This is for while and for loops.

instance method

A method of a class that changes the state of a class. It must be called from an instance of the class.

iteration

A one-time execution of a loop body is referred to as an iteration (or repetition) of the loop

actual parameter

A parameter is like a placeholder: when a method is invoked, you pass a value to the parameter. This value is referred to as an actual parameter or argument.

stubs

A simple but incomplete version of a method—can be used for the methods waiting to be implemented. The use of stubs enables you to quickly build the framework of the program.

format specifier

A special code that begins with a percent sign and specifies the data type and format of the corresponding value.

continue statement

A statement that causes the remainder of the current iteration of a loop to be skipped. The flow of execution goes back to the top of the loop, evaluates the condition, and if this is true the next iteration of the loop will begin.

break statement

A statement that terminates a loop or switch statement.

for loop

A typical looping construct designed to make it easy to repeat a section of code using a counter variable. int i; for (initial-action; loop-continuation-condition; action-after-each-iteration { System.out.println("Welcome to Java!"); }

anonymous array

An array created without an explicit reference. It is an array without any name.

Unicode

An encoding scheme established by the Unicode Consortium to support the interchange, processing, and display of written texts in the world's diverse languages. Unicode was originally designed as a 16-bit character encoding.

escape sequence

An escape character, \, followed by one or more printable characters used to designate a nonprintable character.

supplementary unicode

Are those characters in the Unicode Character Standard outside of the Basic Multilingual Plane (BMP). The BMP consists of the first 64K characters in Unicode. The remaining characters are in the supplementary planes 1-16. Each plane consists of 64K characters.

dangling else ambiguity

Common mistake when else clause does not match the most recent if clause in the same block

linear search

Compares the key element key sequentially with each element in the array. It continues to do so until the key matches an element in the array, or the array is exhausted without a match being found. If a match is made, the linear search returns the index of the element in the array that matches the key. If no match is found, the search returns −1.

nested loop

Consist of an outer loop and one or more inner loops. Each time the outer loop is repeated, the inner loops are reentered, and started anew.

loop

Controls how many times an operation or a sequence of operations is performed in succession. Using a loop statement, you can simply tell the computer to display a string a hundred times without having to code the print statement a hundred times. constructs that control repeated executions of a block of statements. The concept of looping is fundamental to programming. Java provides three types of loop statements: while loops, do-while loops, and for loops.

static method

Defined in an object but do not require instance data. Therefore, they can be called directly with the class name, such as Math.random(). All methods in the Math class are static methods.

DRY

Don't Repeat Yourself

garbage collection

Duplicate an array or a part of an array use: list2 = list1; Copies the reference value from list1 to list2. After this statement, list1 and list2 reference the same array, as shown in Figure 7.4. The array previously referenced by list2 is no longer referenced; it becomes garbage, which will be automatically collected by the Java Virtual Machine.

Boolean expression

Evaluates a boolean structure as either true or false; used in the conditional of an if-structure.

Conditional Operator

Evaluates an expression based on a condition. The symbols ? and : appearing together is called a conditional operator (also known as a ternary operator because it uses three operands. It is the only ternary operator in Java. The conditional operator is in a completely different style, with no explicit if in the statement. Format example: boolean expressionHere = question ! if it's true say this : if it's false say this ;

while loop

Executes statements repeatedly while the condition is true. while (loop-continuation-condition) { // Loop body Statement(s); }

ambiguous invocation

If the compiler finds two or more methods that equally match a given call, it will issue an error. Causes a compile error.

Lazy Operator

In programming language terminology, && and || are known as this aka short-circuit

fall-through behavior

It's what happens in a switch statement once a case is matched: the statements starting from the matched case are executed until a break statement is reached or until the end of the switch statement is reached.

binary search

Looking for an item in an already sorted list by eliminating large portions of the data on each comparison

infinite loop

Make sure that the loop-continuation-condition eventually becomes false so that the loop will terminate. A common programming error involves infinite loops (i.e., the loop runs forever)

encoding

Mapping a character to its binary representation

operator associativity

Rules determining the order in which operations of the same precedence are performed. ** for most operators it is done left to right

output redirection

Sends the output to a file rather than displaying it on the console. java ClassName > output.txt

method abstraction

Separating the use of a method from its implementation. The client can use a method without knowing how it is implemented.

array initializer

Shorthand notation in java. Combines the declaration, creation, and initialization of an array in one statement using the following syntax: elementType[ ] arrayRefVar = {value0, value1, ..., valuek};

array

Stores a fixed-size sequential collection of elements of the same type. A collection of variables of the same type.

information hiding

The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. aka encapsulated.

do-while loop

The loop body is executed first, then the loop-continuation-condition is evaluated. If the evaluation is true, the loop body is executed again; if it is false, the do-while loop terminates.

modifier

The method header specifies the modifiers. 2 types of modifiers access and non-access modifiers

pass by value

The parameter-passing mechanism by which a copy of the value of the actual parameter is passed to the called procedure. If the called procedure modifies the formal parameter, the corresponding actual parameter is not affected. In Java, all primitives are passed-by-value. When you invoke a method with an argument, the value of the argument is passed to the parameter. a pass by value

debugging

The process of finding and correcting errors. Logic errors are called bugs.

input redirection

The program takes the input from the file input.txt rather than having the user type the data from the keyboard at runtime. Obtain the input from a file instead of from the console. java SentinelValue < input.txt

divide and conquer

To decompose it into subproblems. The subproblems can be further decomposed into smaller, more manageable problems. aka stepwise refinement.

method overloading

Two methods have the same name but different parameter lists within one class.

char type

Used to represent a single character.

off-by-one error

Usually seen with loops, this error shows up as a result that is one less or one greater than the expected value. For example, the following loop displays Welcome to Java 101 times rather than 100 times. The error lies in the condition, which should be count < 100 rather than count <= 100. Programmers often mistakenly reference the first element in an array with index 1, but it should be 0.

Whitespace character

a character used to print spaces in text, and includes spaces, tabs, and newline characters The characters ' ', \t, \f, \r, or \n

Boolean data type

a variable that is either true or false

switch statement

allows multi-way branching. In many cases, using a switch statement can simplify a complex combination of if-else statements.

Selection statement

allows us to choose which statement will be executed next based on the evaluation of a boolean condition. Also known as a conditional statement. It can be either an If statement, If-else statement, or Switch statement

indexed variable

arrayRefVar[index];

token based input

reads a string that ends with the Enter key pressed. aka line based input


Ensembles d'études connexes

math study i love math, math is everybody favorite

View Set

Care of Patient's with Noninfectious Upper Respiratory Problems

View Set

ConCrimPro: Fourth Amendment Part 1

View Set

Business Characteristics- Types of Businesses

View Set

Craven ch 30- Respiratory function

View Set