Chapter 4 Flashcards
A portion of a program that repeats a statement or group of statements is called a
loop
The statement or group of statements to be repeated in a loop is called the
body
Each repetition of the loop body is called ___ of the loop
iteration
___ statement repeats its action again and again as long as a controlling boolean expression is true.
while
True or false, A while Loop Can Perform Zero Iterations
True
A loop is always executed at least once.
do-while loop
A loop that iterates its body repeatedly without ever ending is called
infinite loop
What kind of loop enables you to easily write a loop that is controlled by some sort of counter
for-loop
What are the part of for loop called? for (___ ; ____; ____ ) Body
(Initializing_Action; Boolean_Expression; Update_Action)
A semicolon by itself is considered a statement that does nothing, it is called an empty statement or
null statement
The portion of a program in which a variable has meaning is known as the variable’s
scope
We use a comma, not a semicolon, to separate the initialization actions, such a comma is called?
comma operator.
A loop typically involves three elements:
the initializing statements, the loop body, and the mechanism for ending the loop
The two most kind of loop errors are
1- unintended infinite loop 2- off by-one error
What kind of loop error is this “ This error causes your loop to repeat its body either one too many times or one too few times” ?
off by-one error “ Off-by-one errors are caused by an incorrect boolean expression”
True or False; Tracing variables means watching the variables change value while the program is running.
True
What does the method drawString do?
The method drawString is similar to the methods for drawing ovals, but drawString displays text rather than a drawing.