Moment 3 Flashcards
Kap 3 & 4
A procedure for solving a problem in terms of the actions to execute and the order in which they execute is called an?
algorithm
Specifying the order in which statements execute in a program is called?
program control
Pseudocode is an informal language that helps you with?
develop algorithms without having to worry about the strict details of Java language syntax.
Normally, statements in a program are executed one after the other in the order in which they’rewritten. This process is called?
sequential execution
What is transfer of control?
Various Java statements enable you to specify that the next statement to execute is not necessarily the next one in sequence. This is called transfer of control.
Bohm and Jacopini demonstrated that all programs could be written in terms of only three control structures - Which
the sequence structure, the selection structure and the iteration structure.
How does the computer execute Java statements?
Unless directed otherwise, the computer executes Java statements one after the other in the order in which they’re written—that is, in sequence.
What is a activity diagram?
An activity diagram models the workflow of a portion of a software system.
(p. 123; also called the activity)
Activity diagrams are composed of?
symbols — such as action-state symbols, diamonds and small circles—that are connected by transition arrows, which represent the flow of the activity.
(p. 123)
The arrows in an activity diagram represent?
transitions, which indicate the order in which the actions represented by the action states occur.
The solid circle located at the top of an activity diagram represents?
the activity’s initial state —the beginning of the workflow before the program performs the modeled actions.
(p. 123)
The solid circle surrounded by a hollow circle that appears at the bottom of the diagram represents?
the final state —the end of the workflow after the program performs its actions.
(p. 123)
Rectangles with their upper-right corners folded over are UML notes?
explanatory remarks that describe the purpose of symbols in the diagram.
Java has three types of selection statements, which?
if
if…else
switch
What does the if single-selection statement do?
The if single-selection statement selects or ignores one or more actions.
(p. 124)
What does the if…else double-selection statement do?
The if…else double-selection statement selects between two actions or groups of actions.
What does the switch selection statement do?
The switch selection statement selects among many different actions or groups of actions.
(p. 124)
Java provides the while, do…while, for and enhanced for iteration statements that enable programs to?
perform statements repeatedly as long as a loop-continuation condition remains true.
What does the “while”, “do…while” and “for” statements do?
The “while” and “for” statements perform the action(s) in their bodies zero or more times, based on their loop-continuation conditions (p. 124). The “do…while” statement its body one or more times.
What is control-statement stacking?
Single-entry/single-exit control statements are attached to one another by connecting the exit point of one to the entry point of the next. This is known as control-statement stacking.
(p. 124)
The if statement is a?
single-entry/single-exit control statement.
What action dose the “if…else” double-selection statement perform?
The “if…else” double-selection statement performs one action (or group of actions) when the condition is true and another action (or group of actions) when the condition is false.
How can a program test multiple cases?
A program can test multiple cases with nested if…else statements (p. 127).
What is the “Dangling-“else” Problem”
The Java compiler associates an else with the immediately preceding if unless told to do otherwise by the placement of braces.
What is a logic error?
A logic error has its effect at execution time.
p. 129
What is the differences between a fatal logic error and a nonfatal logic error?
A fatal logic error (p. 129) causes a program to fail and terminate prematurely. A nonfatal logic error (p. 129) allows a program to continue executing, but causes it to produce incorrect results.
What dose the The conditional operator ?: do?
The conditional operator ?: takes three operands. Together, the operands and the ?: symbol form a conditional expression. The first operand (to the left of the ?) is a boolean expression, the second is the value of the conditional expression if the condition is true and the third is the value of the conditional expression if the condition is false.
EX: System.out.println (studentGrade >= 60 ? “Passed” : “Failed”);
(p. 129)
What does the “while” iteration statement do?
The while iteration statement allows you to specify that a program should repeat an action while some condition remains true.
(p. 130)
What does the UML’s merge symbol do?
The UML’s merge symbol joins two flows of activity into one.
(p. 130)
How do you distinguish the differences between the UML’s decision and merge symbols
The decision and merge symbols can be distinguished by the number of incoming and outgoing transition arrows. A decision symbol has one transition arrow pointing to the diamond and two or more transition arrows pointing out from the diamond to indicate possible transitions from that point. Each transition arrow pointing out of a decision symbol has a guard condition. A merge symbol has two or more transition arrows pointing to the diamond and only one transition arrow pointing from the diamond, to indicate multiple activity flows merging to continue the activity. None of the transition arrows associated with a merge symbol has a guard condition.
Counter-controlled iteration uses a variable called a?
a counter (or control variable) to control the number of times a set of statements execute.
(p. 131)
Counter-controlled iteration is often called?
definite iteration, because the number of iterations is known before the loop begins executing.
(p. 131)
A total is a variable used to?
accumulate the sum of several values. Variables used to store totals are normally initialized to zero before being used in a program.
(p. 131)
A local variable’s declaration must appear?
before the variable is used in that method. A local variable cannot be accessed outside the method in which it’s declared.
Dividing two integers results in?
integer division—the calculation’s fractional part is truncated.
In sentinel-controlled iteration, a special value called ________ is used?
In sentinel-controlled iteration, a special value called a sentinel value (also called a signal value, a dummy value or a flag value) is used to indicate “end of data entry.”
(p. 135)
A sentinel value must be chosen that?
That it cannot be confused with an acceptable input value.
What is essential to the development of well-structured programs?
Top-down, step-wise refinement.
p. 135
Division by zero is a?
logic error.
How to perform a floating-point calculation with integer values?
cast one of the integers to type double.
What is promotion on selected operands?
Java knows how to evaluate only arithmetic expressions in which the operands’ types are identical.
To ensure this, Java performs an operation called promotion on selected operands.
The unary cast operator is formed by?
placing parentheses around the name of a type.
What are compound assignment operators?
The compound assignment operators abbreviate assignments. Statements of the form:
variable = variable operator expression;
where operator is one of the binary operators +, -, *, / or %, can be written in the form
variable operator= expression;
(p. 146)
What does the “+=” operator do?
The += operator adds the value of the expression on the right of the operator to the value of the variable on the left of the operator and stores the result in the variable on the left of the operator.
What are the Increment and Decrement Operators, and what do they do?
The unary increment operator, ++, and the unary decrement operator, –, add 1 to or subtract 1 from the value of a numeric variable.
(p. 147).
What is the difference between prefix and postfixed decrement operator?
An increment or decrement operator that’s prefixed to a variable is the prefix increment or prefix decrement operator, respectively. An increment or decrement operator that’s postfixet to a variable is the postfix increment or postfix decrement operator, respectively.
(p. 147)
Using the prefix increment or decrement operator to add or subtract 1 is known as?
preincrementing or predecrementing, respectively.
Using the postfix increment or decrement operator to add or subtract 1 is known as?
postincrementing or postdecrementing, respectively.
All programs can be written in terms of three types of control structures: ________ ,________ and ___________ .
sequence, selection, iteration.
The ___________ statement is used to execute one action when a condition is true and another when that condition is false.
if…else.
Repeating a set of instructions a specific number of times is called ____________ iteration.
counter-controlled (or definite).
When it’s not known in advance how many times a set of statements will be repeated, a(n) ___________ value can be used to terminate the iteration.
sentinel, signal, flag or dummy.
The ______________ is built into Java; by default, statements execute in the order they appear.
sequence structure.
If the increment operator is ________________ to a variable, first the variable is incremented by 1, then its new value is used in the expression.
prefixed.
When the declaration int y = 5; is followed by the assignment y += 3.3; the value of y is ________________ .
[Note: You might expect a compilation error on the assignment statement. The Java Language Specification says that compound assignment operators perform an implicit cast on the right-hand expression’s value to match the type of the variable on the operator’s left side. So the calculated value 5 + 3.3 = 8.3 is actually cast to the int value 8.].