Deck 6: Looping

ملء الشاشة (f)
exit full mode
سؤال
It is important that the loop control ____ be altered within the body of the loop.

A) value
B) variable
C) constant
D) argument
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Before entering a loop, the first input statement, or ____, is retrieved.

A) empty body
B) posttest loop
C) loop body
D) priming read
سؤال
A counted loop is the same as an indefinite loop.
سؤال
Many seasoned programmers start counter values at 1 because they are used to doing so when working with arrays.
سؤال
Making a comparison to 0 is slower than making a comparison to any other value.
سؤال
Use a(n) ____ loop to execute a body of statements continually as long as the Boolean expression that controls entry into the loop continues to be true .

A) empty
B) while
C) definite
D) control
سؤال
Programmers rarely use indefinite loops when validating input data.
سؤال
When nesting loops, the variable in the outer loop changes more frequently.
سؤال
A(n) ____ is a kind of indefinite loop.

A) counter-controlled
B) event-controlled
C) initialized
D) validating
سؤال
You can use virtually any number of nested loops; however, at some point, your machine will no longer be able to store all the necessary looping information.
سؤال
On many keyboards, the Break key is also the ____ key.

A) Pause
B) Esc
C) Delete
D) Ctrl
سؤال
You can initialize one or more variables in the first section of a  for  statement.
سؤال
The statements that make up a loop body will continue to execute as long as the expression value remains false.
سؤال
Which is an infinite loop?

A) loopCount = 5; while(loopCount > 3);
{
   System.out.println("Hello");
   loopCount = loopCount - 1;
}
B) loopCount = 1; while(loopCount < 3);
{
   System.out.println("Hello");
}
C) loopCount = 4; while(loopCount < 3);
{
   System.out.println("Hello");
   loopCount = loopCount + 1;
}
D) loopCount = 1; while(loopCount < 3);
{
   System.out.println("Hello");
   loopCount = loopCount + 1;
}
سؤال
In order to improve loop performance, it's important to make sure the loop does not include unnecessary operations or statements.
سؤال
A ____ is a structure that allows repeated execution of a block of statements.

A) body
B) Boolean expression
C) loop
D) loop control
سؤال
A loop controlled by the user is a type of ____ loop.

A) indefinite
B) definite
C) counter-controlled
D) incrementing
سؤال
____ is the process of ensuring that a value falls within a specified range.

A) Value checking
B) Data integrity
C) Validating data
D) Syntax checking
سؤال
A loop that never ends is called a(n) ____ loop.

A) definite
B) infinite
C) while
D) for
سؤال
Shortcut operators are a programmer's only choice when incrementing or accumulating a variable's value.
سؤال
A(n) ____ loop is a special loop that is used when a definite number of loop iterations is required.

A) while
B) for
C) else
D) do…while
سؤال
What is wrong with the following code? x=1;
While (x<5);
 { System.out.println (x);
   x++;
}

A) Syntax error in the println method
B) Incorrect use of prefix increment operator
C) Semicolon at the end of the while expression
D) Incorrect initialization
سؤال
The ____ loop is the posttest loop used in Java.

A) for
B) counter-controlled
C) while
D) do...while
سؤال
Assume  d and x are integers: d = 5;
X = 2 * ++d;
What is the value of x ?

A) 10
B) 11
C) 12
D) 13
سؤال
With ____ loops, the order of the conditional expressions can be important.

A) nested
B) posttest
C) pretest
D) indefinite
سؤال
When creating a for loop, which statement will correctly initialize more than one variable?

A) for a=1, b=2
B) for(a=1; b=2)
C) for(a=1, b=2)
D) for(a = 1&& b = 2)
سؤال
A(n) ____ loop is one that performs no actions other than looping.

A) nested
B) do-nothing
C) indefinite
D) posttest
سؤال
One execution of any loop is called a(n) ____.

A) run
B) loop
C) prime
D) iteration
سؤال
The ____ loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.

A) while
B) do…while
C) for
D) else
سؤال
____ is a technique that can improve loop performance by combining two loops into one.

A) Loop fusion
B) Prefix incrementing
C) Short-circuit evaluation
D) Do-nothing looping
سؤال
When you want to increase a variable's value by exactly 1, use the ____.

A) power statement
B) accumulating operator
C) binary operators
D) prefix increment operator
سؤال
In the expressions b = 8 and c = --b , what value will be assigned to the variable c ?

A) 7
B) 8
C) 9
D) 10
سؤال
You can initialize more than one variable in a for loop by placing a(n) ____ between the separate statements.

A) semicolon
B) equal sign
C) period
D) comma
سؤال
A for loop provides a convenient way to create a(n) ____ loop.

A) counter-controlled
B) posttest
C) while
D) infinite
سؤال
A(n) ____ is a body with no statements in it.

A) infinite loop
B) empty body
C) finite loop
D) event-controlled loop
سؤال
In a do…while loop, the loop will continue to execute until ____.

A) the loop control variable is true
B) the loop control variable is false
C) the user types EXIT
D) the program terminates
سؤال
Which of the following is NOT a valid method to increase a variable named score by 1?

A) ++score
B) score++
C) ++score = score + 1
D) score = score + 1
سؤال
You use a unary minus sign preceding a value to make the value ____.

A) negative
B) positive
C) valid
D) constant
سؤال
How many times will outputLabel be called? for(customer = 1; customer <= 20; ++customer)
     for(color = 1; color <= 3; ++color)
          outputLabel();

A) 0
B) 3
C) 20
D) 60
سؤال
The process of repeatedly increasing a value by some amount is known as ____.

A) checking
B) adding
C) accumulating
D) containing
سؤال
Match between columns
The technique of combining two loops into one
prefix ++
The technique of combining two loops into one
block
The technique of combining two loops into one
definite loop
The technique of combining two loops into one
loop control variable
The technique of combining two loops into one
binary operators
The technique of combining two loops into one
loop fusion
The technique of combining two loops into one
decrementing
The technique of combining two loops into one
for loop
The technique of combining two loops into one
sleep() method
The technique of combining two loops into one
empty body
The technique of combining two loops into one
do-nothing loop
The technique of combining two loops into one
*=
The technique of combining two loops into one
data validation
The technique of combining two loops into one
accumulating
The technique of combining two loops into one
% =
سؤال
What is wrong with the following code? while (4>2)
 System.out.println ("Hi there");

A) missing curly braces
B) illegal conditional expression
C) infinite loop
D) Syntax error in the output statement
سؤال
Match between columns
Within parentheses are three sections separated by exactly two semicolons
prefix ++
Within parentheses are three sections separated by exactly two semicolons
block
Within parentheses are three sections separated by exactly two semicolons
definite loop
Within parentheses are three sections separated by exactly two semicolons
loop control variable
Within parentheses are three sections separated by exactly two semicolons
binary operators
Within parentheses are three sections separated by exactly two semicolons
loop fusion
Within parentheses are three sections separated by exactly two semicolons
decrementing
Within parentheses are three sections separated by exactly two semicolons
for loop
Within parentheses are three sections separated by exactly two semicolons
sleep() method
Within parentheses are three sections separated by exactly two semicolons
empty body
Within parentheses are three sections separated by exactly two semicolons
do-nothing loop
Within parentheses are three sections separated by exactly two semicolons
*=
Within parentheses are three sections separated by exactly two semicolons
data validation
Within parentheses are three sections separated by exactly two semicolons
accumulating
Within parentheses are three sections separated by exactly two semicolons
% =
سؤال
Match between columns
A counted loop
prefix ++
A counted loop
block
A counted loop
definite loop
A counted loop
loop control variable
A counted loop
binary operators
A counted loop
loop fusion
A counted loop
decrementing
A counted loop
for loop
A counted loop
sleep() method
A counted loop
empty body
A counted loop
do-nothing loop
A counted loop
*=
A counted loop
data validation
A counted loop
accumulating
A counted loop
% =
سؤال
Match between columns
Operate on two values
prefix ++
Operate on two values
block
Operate on two values
definite loop
Operate on two values
loop control variable
Operate on two values
binary operators
Operate on two values
loop fusion
Operate on two values
decrementing
Operate on two values
for loop
Operate on two values
sleep() method
Operate on two values
empty body
Operate on two values
do-nothing loop
Operate on two values
*=
Operate on two values
data validation
Operate on two values
accumulating
Operate on two values
% =
سؤال
Match between columns
A body with no statements
prefix ++
A body with no statements
block
A body with no statements
definite loop
A body with no statements
loop control variable
A body with no statements
binary operators
A body with no statements
loop fusion
A body with no statements
decrementing
A body with no statements
for loop
A body with no statements
sleep() method
A body with no statements
empty body
A body with no statements
do-nothing loop
A body with no statements
*=
A body with no statements
data validation
A body with no statements
accumulating
A body with no statements
% =
سؤال
What is the output of the following code: loopCount = 1;
While(loopCount < 3)
{
   System.out.println("Hello");
   loopCount = loopCount + 1;
}

A) Hello
B) Hello Hello
C) Hello Hello
Hello
D) HelloHello
سؤال
What is the output of the following code: for (loop = 1; loop <3; ++loop)
   System.out.print(1);
   for (loop2 = 1; loop2< 3; ++loop2)
      System.out.print(2);

A) 112222
B) 1232212322
C) 122122
D) 122212221222
سؤال
Match between columns
Part of the Thread class in the java.lang package
prefix ++
Part of the Thread class in the java.lang package
block
Part of the Thread class in the java.lang package
definite loop
Part of the Thread class in the java.lang package
loop control variable
Part of the Thread class in the java.lang package
binary operators
Part of the Thread class in the java.lang package
loop fusion
Part of the Thread class in the java.lang package
decrementing
Part of the Thread class in the java.lang package
for loop
Part of the Thread class in the java.lang package
sleep() method
Part of the Thread class in the java.lang package
empty body
Part of the Thread class in the java.lang package
do-nothing loop
Part of the Thread class in the java.lang package
*=
Part of the Thread class in the java.lang package
data validation
Part of the Thread class in the java.lang package
accumulating
Part of the Thread class in the java.lang package
% =
سؤال
Match between columns
Remainder and assign
prefix ++
Remainder and assign
block
Remainder and assign
definite loop
Remainder and assign
loop control variable
Remainder and assign
binary operators
Remainder and assign
loop fusion
Remainder and assign
decrementing
Remainder and assign
for loop
Remainder and assign
sleep() method
Remainder and assign
empty body
Remainder and assign
do-nothing loop
Remainder and assign
*=
Remainder and assign
data validation
Remainder and assign
accumulating
Remainder and assign
% =
سؤال
Match between columns
Performs no actions in its body
prefix ++
Performs no actions in its body
block
Performs no actions in its body
definite loop
Performs no actions in its body
loop control variable
Performs no actions in its body
binary operators
Performs no actions in its body
loop fusion
Performs no actions in its body
decrementing
Performs no actions in its body
for loop
Performs no actions in its body
sleep() method
Performs no actions in its body
empty body
Performs no actions in its body
do-nothing loop
Performs no actions in its body
*=
Performs no actions in its body
data validation
Performs no actions in its body
accumulating
Performs no actions in its body
% =
سؤال
Match between columns
Repeatedly increasing a value by an amount
prefix ++
Repeatedly increasing a value by an amount
block
Repeatedly increasing a value by an amount
definite loop
Repeatedly increasing a value by an amount
loop control variable
Repeatedly increasing a value by an amount
binary operators
Repeatedly increasing a value by an amount
loop fusion
Repeatedly increasing a value by an amount
decrementing
Repeatedly increasing a value by an amount
for loop
Repeatedly increasing a value by an amount
sleep() method
Repeatedly increasing a value by an amount
empty body
Repeatedly increasing a value by an amount
do-nothing loop
Repeatedly increasing a value by an amount
*=
Repeatedly increasing a value by an amount
data validation
Repeatedly increasing a value by an amount
accumulating
Repeatedly increasing a value by an amount
% =
سؤال
Match between columns
Multiply and assign
prefix ++
Multiply and assign
block
Multiply and assign
definite loop
Multiply and assign
loop control variable
Multiply and assign
binary operators
Multiply and assign
loop fusion
Multiply and assign
decrementing
Multiply and assign
for loop
Multiply and assign
sleep() method
Multiply and assign
empty body
Multiply and assign
do-nothing loop
Multiply and assign
*=
Multiply and assign
data validation
Multiply and assign
accumulating
Multiply and assign
% =
سؤال
What is the output of the following code:​ loopCount = 1;
While(loopCount < 3)
   System.out.println("Hello");
   loopCount = loopCount + 1;

A) No output
B) Hello Hello
C) Hello Hello
Hello
D) This is an infinite loop
سؤال
Match between columns
A shortcut for incrementing and accumulating
prefix ++
A shortcut for incrementing and accumulating
block
A shortcut for incrementing and accumulating
definite loop
A shortcut for incrementing and accumulating
loop control variable
A shortcut for incrementing and accumulating
binary operators
A shortcut for incrementing and accumulating
loop fusion
A shortcut for incrementing and accumulating
decrementing
A shortcut for incrementing and accumulating
for loop
A shortcut for incrementing and accumulating
sleep() method
A shortcut for incrementing and accumulating
empty body
A shortcut for incrementing and accumulating
do-nothing loop
A shortcut for incrementing and accumulating
*=
A shortcut for incrementing and accumulating
data validation
A shortcut for incrementing and accumulating
accumulating
A shortcut for incrementing and accumulating
% =
سؤال
Match between columns
Ensuring that a value is in a range
prefix ++
Ensuring that a value is in a range
block
Ensuring that a value is in a range
definite loop
Ensuring that a value is in a range
loop control variable
Ensuring that a value is in a range
binary operators
Ensuring that a value is in a range
loop fusion
Ensuring that a value is in a range
decrementing
Ensuring that a value is in a range
for loop
Ensuring that a value is in a range
sleep() method
Ensuring that a value is in a range
empty body
Ensuring that a value is in a range
do-nothing loop
Ensuring that a value is in a range
*=
Ensuring that a value is in a range
data validation
Ensuring that a value is in a range
accumulating
Ensuring that a value is in a range
% =
سؤال
Match between columns
Subtracting 1 from a variable
prefix ++
Subtracting 1 from a variable
block
Subtracting 1 from a variable
definite loop
Subtracting 1 from a variable
loop control variable
Subtracting 1 from a variable
binary operators
Subtracting 1 from a variable
loop fusion
Subtracting 1 from a variable
decrementing
Subtracting 1 from a variable
for loop
Subtracting 1 from a variable
sleep() method
Subtracting 1 from a variable
empty body
Subtracting 1 from a variable
do-nothing loop
Subtracting 1 from a variable
*=
Subtracting 1 from a variable
data validation
Subtracting 1 from a variable
accumulating
Subtracting 1 from a variable
% =
سؤال
What kind of loop is this: response = keyboard.nextInt();
While (response == 1)
{
    System.out.print ("Enter 1 to continue; 0 to stop");
    response = keyboard.nextInt();
}

A) posttest
B) definite
C) event-driven
D) counted
سؤال
Match between columns
The value that determines whether loop execution continues
prefix ++
The value that determines whether loop execution continues
block
The value that determines whether loop execution continues
definite loop
The value that determines whether loop execution continues
loop control variable
The value that determines whether loop execution continues
binary operators
The value that determines whether loop execution continues
loop fusion
The value that determines whether loop execution continues
decrementing
The value that determines whether loop execution continues
for loop
The value that determines whether loop execution continues
sleep() method
The value that determines whether loop execution continues
empty body
The value that determines whether loop execution continues
do-nothing loop
The value that determines whether loop execution continues
*=
The value that determines whether loop execution continues
data validation
The value that determines whether loop execution continues
accumulating
The value that determines whether loop execution continues
% =
سؤال
Match between columns
Multiple statements within curly braces
prefix ++
Multiple statements within curly braces
block
Multiple statements within curly braces
definite loop
Multiple statements within curly braces
loop control variable
Multiple statements within curly braces
binary operators
Multiple statements within curly braces
loop fusion
Multiple statements within curly braces
decrementing
Multiple statements within curly braces
for loop
Multiple statements within curly braces
sleep() method
Multiple statements within curly braces
empty body
Multiple statements within curly braces
do-nothing loop
Multiple statements within curly braces
*=
Multiple statements within curly braces
data validation
Multiple statements within curly braces
accumulating
Multiple statements within curly braces
% =
سؤال
Why would a loop with altered user input be considered a type of indefinite loop? Give an example.
سؤال
What would happen if a semicolon is mistakenly placed at the end of a partial statement of a while loop with a Boolean expression and with an empty body?
سؤال
Explain why an infinite loop might not actually execute infinitely.
سؤال
How could a programmer identify and escape from an infinite loop?
سؤال

while(count < getNumberOfEmployees())
Examine the statement above. Write the code that will result in more efficient program execution assuming the result of getNumberOfEmployees() stays the same.
سؤال
How are indefinite loops used for validating data? Why is a loop structure typically the better choice for validating data than an if statement?
سؤال
How does a for loop work?
سؤال
Describe how a loop is controlled by a Boolean expression.
سؤال
Provide a code example of a pretest loop and an example of a posttest loop.
سؤال
What are some unconventional uses of the three sections inside the parentheses of a  for loop? Show at least three examples using code.
سؤال
What is loop fusion? Write a code segment that uses loop fusion to call two methods, method1 and method2 , 10 times each.
سؤال
counterLoop = 1;
while(counterLoop < 10);
{
     System.out.println("Hello");
     counterLoop = counterLoop + 1;
}
What is the problem in the above while loop? How would you correct the problem?
سؤال
public class IncrDemo
{
    public static void main(String[] args)
    {
      int myVal, yourVal;
      myVal = 10;
      System.out.println("My initial value is " + myVal);
      yourVal = ++myVal;
      System.out.println("My new value is " + myVal);
      System.out.println("Your value is " + yourVal):
    }
}
Using the above code, describe how the three println output commands will appear. Explain the values stored in the variables during code execution.
سؤال
How are nested loops implemented in a loop structure?
سؤال
while(10 > 1)
{
   System.out.println("This prints forever.");
}
Identify the problem that exists in the above while loop.
سؤال
​What are the three sections inside the parentheses of a for loop typically used for?
سؤال
How could you rewrite the following code to have the arithmetic performed only once, even if the loop executes 1,000 times?
while (x < a + b)
// loop body
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/77
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: Looping
1
It is important that the loop control ____ be altered within the body of the loop.

A) value
B) variable
C) constant
D) argument
B
2
Before entering a loop, the first input statement, or ____, is retrieved.

A) empty body
B) posttest loop
C) loop body
D) priming read
D
3
A counted loop is the same as an indefinite loop.
False
4
Many seasoned programmers start counter values at 1 because they are used to doing so when working with arrays.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
5
Making a comparison to 0 is slower than making a comparison to any other value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
6
Use a(n) ____ loop to execute a body of statements continually as long as the Boolean expression that controls entry into the loop continues to be true .

A) empty
B) while
C) definite
D) control
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
7
Programmers rarely use indefinite loops when validating input data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
8
When nesting loops, the variable in the outer loop changes more frequently.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
9
A(n) ____ is a kind of indefinite loop.

A) counter-controlled
B) event-controlled
C) initialized
D) validating
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
10
You can use virtually any number of nested loops; however, at some point, your machine will no longer be able to store all the necessary looping information.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
11
On many keyboards, the Break key is also the ____ key.

A) Pause
B) Esc
C) Delete
D) Ctrl
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
12
You can initialize one or more variables in the first section of a  for  statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
13
The statements that make up a loop body will continue to execute as long as the expression value remains false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which is an infinite loop?

A) loopCount = 5; while(loopCount > 3);
{
   System.out.println("Hello");
   loopCount = loopCount - 1;
}
B) loopCount = 1; while(loopCount < 3);
{
   System.out.println("Hello");
}
C) loopCount = 4; while(loopCount < 3);
{
   System.out.println("Hello");
   loopCount = loopCount + 1;
}
D) loopCount = 1; while(loopCount < 3);
{
   System.out.println("Hello");
   loopCount = loopCount + 1;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
15
In order to improve loop performance, it's important to make sure the loop does not include unnecessary operations or statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
16
A ____ is a structure that allows repeated execution of a block of statements.

A) body
B) Boolean expression
C) loop
D) loop control
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
17
A loop controlled by the user is a type of ____ loop.

A) indefinite
B) definite
C) counter-controlled
D) incrementing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
18
____ is the process of ensuring that a value falls within a specified range.

A) Value checking
B) Data integrity
C) Validating data
D) Syntax checking
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
19
A loop that never ends is called a(n) ____ loop.

A) definite
B) infinite
C) while
D) for
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
20
Shortcut operators are a programmer's only choice when incrementing or accumulating a variable's value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
21
A(n) ____ loop is a special loop that is used when a definite number of loop iterations is required.

A) while
B) for
C) else
D) do…while
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
22
What is wrong with the following code? x=1;
While (x<5);
 { System.out.println (x);
   x++;
}

A) Syntax error in the println method
B) Incorrect use of prefix increment operator
C) Semicolon at the end of the while expression
D) Incorrect initialization
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
23
The ____ loop is the posttest loop used in Java.

A) for
B) counter-controlled
C) while
D) do...while
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
24
Assume  d and x are integers: d = 5;
X = 2 * ++d;
What is the value of x ?

A) 10
B) 11
C) 12
D) 13
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
25
With ____ loops, the order of the conditional expressions can be important.

A) nested
B) posttest
C) pretest
D) indefinite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
26
When creating a for loop, which statement will correctly initialize more than one variable?

A) for a=1, b=2
B) for(a=1; b=2)
C) for(a=1, b=2)
D) for(a = 1&& b = 2)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
27
A(n) ____ loop is one that performs no actions other than looping.

A) nested
B) do-nothing
C) indefinite
D) posttest
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
28
One execution of any loop is called a(n) ____.

A) run
B) loop
C) prime
D) iteration
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
29
The ____ loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.

A) while
B) do…while
C) for
D) else
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
30
____ is a technique that can improve loop performance by combining two loops into one.

A) Loop fusion
B) Prefix incrementing
C) Short-circuit evaluation
D) Do-nothing looping
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
31
When you want to increase a variable's value by exactly 1, use the ____.

A) power statement
B) accumulating operator
C) binary operators
D) prefix increment operator
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
32
In the expressions b = 8 and c = --b , what value will be assigned to the variable c ?

A) 7
B) 8
C) 9
D) 10
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
33
You can initialize more than one variable in a for loop by placing a(n) ____ between the separate statements.

A) semicolon
B) equal sign
C) period
D) comma
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
34
A for loop provides a convenient way to create a(n) ____ loop.

A) counter-controlled
B) posttest
C) while
D) infinite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
35
A(n) ____ is a body with no statements in it.

A) infinite loop
B) empty body
C) finite loop
D) event-controlled loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
36
In a do…while loop, the loop will continue to execute until ____.

A) the loop control variable is true
B) the loop control variable is false
C) the user types EXIT
D) the program terminates
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
37
Which of the following is NOT a valid method to increase a variable named score by 1?

A) ++score
B) score++
C) ++score = score + 1
D) score = score + 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
38
You use a unary minus sign preceding a value to make the value ____.

A) negative
B) positive
C) valid
D) constant
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
39
How many times will outputLabel be called? for(customer = 1; customer <= 20; ++customer)
     for(color = 1; color <= 3; ++color)
          outputLabel();

A) 0
B) 3
C) 20
D) 60
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
40
The process of repeatedly increasing a value by some amount is known as ____.

A) checking
B) adding
C) accumulating
D) containing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
The technique of combining two loops into one
prefix ++
The technique of combining two loops into one
block
The technique of combining two loops into one
definite loop
The technique of combining two loops into one
loop control variable
The technique of combining two loops into one
binary operators
The technique of combining two loops into one
loop fusion
The technique of combining two loops into one
decrementing
The technique of combining two loops into one
for loop
The technique of combining two loops into one
sleep() method
The technique of combining two loops into one
empty body
The technique of combining two loops into one
do-nothing loop
The technique of combining two loops into one
*=
The technique of combining two loops into one
data validation
The technique of combining two loops into one
accumulating
The technique of combining two loops into one
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
42
What is wrong with the following code? while (4>2)
 System.out.println ("Hi there");

A) missing curly braces
B) illegal conditional expression
C) infinite loop
D) Syntax error in the output statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
43
Match between columns
Within parentheses are three sections separated by exactly two semicolons
prefix ++
Within parentheses are three sections separated by exactly two semicolons
block
Within parentheses are three sections separated by exactly two semicolons
definite loop
Within parentheses are three sections separated by exactly two semicolons
loop control variable
Within parentheses are three sections separated by exactly two semicolons
binary operators
Within parentheses are three sections separated by exactly two semicolons
loop fusion
Within parentheses are three sections separated by exactly two semicolons
decrementing
Within parentheses are three sections separated by exactly two semicolons
for loop
Within parentheses are three sections separated by exactly two semicolons
sleep() method
Within parentheses are three sections separated by exactly two semicolons
empty body
Within parentheses are three sections separated by exactly two semicolons
do-nothing loop
Within parentheses are three sections separated by exactly two semicolons
*=
Within parentheses are three sections separated by exactly two semicolons
data validation
Within parentheses are three sections separated by exactly two semicolons
accumulating
Within parentheses are three sections separated by exactly two semicolons
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
44
Match between columns
A counted loop
prefix ++
A counted loop
block
A counted loop
definite loop
A counted loop
loop control variable
A counted loop
binary operators
A counted loop
loop fusion
A counted loop
decrementing
A counted loop
for loop
A counted loop
sleep() method
A counted loop
empty body
A counted loop
do-nothing loop
A counted loop
*=
A counted loop
data validation
A counted loop
accumulating
A counted loop
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
45
Match between columns
Operate on two values
prefix ++
Operate on two values
block
Operate on two values
definite loop
Operate on two values
loop control variable
Operate on two values
binary operators
Operate on two values
loop fusion
Operate on two values
decrementing
Operate on two values
for loop
Operate on two values
sleep() method
Operate on two values
empty body
Operate on two values
do-nothing loop
Operate on two values
*=
Operate on two values
data validation
Operate on two values
accumulating
Operate on two values
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
46
Match between columns
A body with no statements
prefix ++
A body with no statements
block
A body with no statements
definite loop
A body with no statements
loop control variable
A body with no statements
binary operators
A body with no statements
loop fusion
A body with no statements
decrementing
A body with no statements
for loop
A body with no statements
sleep() method
A body with no statements
empty body
A body with no statements
do-nothing loop
A body with no statements
*=
A body with no statements
data validation
A body with no statements
accumulating
A body with no statements
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
47
What is the output of the following code: loopCount = 1;
While(loopCount < 3)
{
   System.out.println("Hello");
   loopCount = loopCount + 1;
}

A) Hello
B) Hello Hello
C) Hello Hello
Hello
D) HelloHello
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
48
What is the output of the following code: for (loop = 1; loop <3; ++loop)
   System.out.print(1);
   for (loop2 = 1; loop2< 3; ++loop2)
      System.out.print(2);

A) 112222
B) 1232212322
C) 122122
D) 122212221222
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
49
Match between columns
Part of the Thread class in the java.lang package
prefix ++
Part of the Thread class in the java.lang package
block
Part of the Thread class in the java.lang package
definite loop
Part of the Thread class in the java.lang package
loop control variable
Part of the Thread class in the java.lang package
binary operators
Part of the Thread class in the java.lang package
loop fusion
Part of the Thread class in the java.lang package
decrementing
Part of the Thread class in the java.lang package
for loop
Part of the Thread class in the java.lang package
sleep() method
Part of the Thread class in the java.lang package
empty body
Part of the Thread class in the java.lang package
do-nothing loop
Part of the Thread class in the java.lang package
*=
Part of the Thread class in the java.lang package
data validation
Part of the Thread class in the java.lang package
accumulating
Part of the Thread class in the java.lang package
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
50
Match between columns
Remainder and assign
prefix ++
Remainder and assign
block
Remainder and assign
definite loop
Remainder and assign
loop control variable
Remainder and assign
binary operators
Remainder and assign
loop fusion
Remainder and assign
decrementing
Remainder and assign
for loop
Remainder and assign
sleep() method
Remainder and assign
empty body
Remainder and assign
do-nothing loop
Remainder and assign
*=
Remainder and assign
data validation
Remainder and assign
accumulating
Remainder and assign
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
51
Match between columns
Performs no actions in its body
prefix ++
Performs no actions in its body
block
Performs no actions in its body
definite loop
Performs no actions in its body
loop control variable
Performs no actions in its body
binary operators
Performs no actions in its body
loop fusion
Performs no actions in its body
decrementing
Performs no actions in its body
for loop
Performs no actions in its body
sleep() method
Performs no actions in its body
empty body
Performs no actions in its body
do-nothing loop
Performs no actions in its body
*=
Performs no actions in its body
data validation
Performs no actions in its body
accumulating
Performs no actions in its body
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
52
Match between columns
Repeatedly increasing a value by an amount
prefix ++
Repeatedly increasing a value by an amount
block
Repeatedly increasing a value by an amount
definite loop
Repeatedly increasing a value by an amount
loop control variable
Repeatedly increasing a value by an amount
binary operators
Repeatedly increasing a value by an amount
loop fusion
Repeatedly increasing a value by an amount
decrementing
Repeatedly increasing a value by an amount
for loop
Repeatedly increasing a value by an amount
sleep() method
Repeatedly increasing a value by an amount
empty body
Repeatedly increasing a value by an amount
do-nothing loop
Repeatedly increasing a value by an amount
*=
Repeatedly increasing a value by an amount
data validation
Repeatedly increasing a value by an amount
accumulating
Repeatedly increasing a value by an amount
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
53
Match between columns
Multiply and assign
prefix ++
Multiply and assign
block
Multiply and assign
definite loop
Multiply and assign
loop control variable
Multiply and assign
binary operators
Multiply and assign
loop fusion
Multiply and assign
decrementing
Multiply and assign
for loop
Multiply and assign
sleep() method
Multiply and assign
empty body
Multiply and assign
do-nothing loop
Multiply and assign
*=
Multiply and assign
data validation
Multiply and assign
accumulating
Multiply and assign
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
54
What is the output of the following code:​ loopCount = 1;
While(loopCount < 3)
   System.out.println("Hello");
   loopCount = loopCount + 1;

A) No output
B) Hello Hello
C) Hello Hello
Hello
D) This is an infinite loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
55
Match between columns
A shortcut for incrementing and accumulating
prefix ++
A shortcut for incrementing and accumulating
block
A shortcut for incrementing and accumulating
definite loop
A shortcut for incrementing and accumulating
loop control variable
A shortcut for incrementing and accumulating
binary operators
A shortcut for incrementing and accumulating
loop fusion
A shortcut for incrementing and accumulating
decrementing
A shortcut for incrementing and accumulating
for loop
A shortcut for incrementing and accumulating
sleep() method
A shortcut for incrementing and accumulating
empty body
A shortcut for incrementing and accumulating
do-nothing loop
A shortcut for incrementing and accumulating
*=
A shortcut for incrementing and accumulating
data validation
A shortcut for incrementing and accumulating
accumulating
A shortcut for incrementing and accumulating
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
56
Match between columns
Ensuring that a value is in a range
prefix ++
Ensuring that a value is in a range
block
Ensuring that a value is in a range
definite loop
Ensuring that a value is in a range
loop control variable
Ensuring that a value is in a range
binary operators
Ensuring that a value is in a range
loop fusion
Ensuring that a value is in a range
decrementing
Ensuring that a value is in a range
for loop
Ensuring that a value is in a range
sleep() method
Ensuring that a value is in a range
empty body
Ensuring that a value is in a range
do-nothing loop
Ensuring that a value is in a range
*=
Ensuring that a value is in a range
data validation
Ensuring that a value is in a range
accumulating
Ensuring that a value is in a range
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
57
Match between columns
Subtracting 1 from a variable
prefix ++
Subtracting 1 from a variable
block
Subtracting 1 from a variable
definite loop
Subtracting 1 from a variable
loop control variable
Subtracting 1 from a variable
binary operators
Subtracting 1 from a variable
loop fusion
Subtracting 1 from a variable
decrementing
Subtracting 1 from a variable
for loop
Subtracting 1 from a variable
sleep() method
Subtracting 1 from a variable
empty body
Subtracting 1 from a variable
do-nothing loop
Subtracting 1 from a variable
*=
Subtracting 1 from a variable
data validation
Subtracting 1 from a variable
accumulating
Subtracting 1 from a variable
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
58
What kind of loop is this: response = keyboard.nextInt();
While (response == 1)
{
    System.out.print ("Enter 1 to continue; 0 to stop");
    response = keyboard.nextInt();
}

A) posttest
B) definite
C) event-driven
D) counted
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
59
Match between columns
The value that determines whether loop execution continues
prefix ++
The value that determines whether loop execution continues
block
The value that determines whether loop execution continues
definite loop
The value that determines whether loop execution continues
loop control variable
The value that determines whether loop execution continues
binary operators
The value that determines whether loop execution continues
loop fusion
The value that determines whether loop execution continues
decrementing
The value that determines whether loop execution continues
for loop
The value that determines whether loop execution continues
sleep() method
The value that determines whether loop execution continues
empty body
The value that determines whether loop execution continues
do-nothing loop
The value that determines whether loop execution continues
*=
The value that determines whether loop execution continues
data validation
The value that determines whether loop execution continues
accumulating
The value that determines whether loop execution continues
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
60
Match between columns
Multiple statements within curly braces
prefix ++
Multiple statements within curly braces
block
Multiple statements within curly braces
definite loop
Multiple statements within curly braces
loop control variable
Multiple statements within curly braces
binary operators
Multiple statements within curly braces
loop fusion
Multiple statements within curly braces
decrementing
Multiple statements within curly braces
for loop
Multiple statements within curly braces
sleep() method
Multiple statements within curly braces
empty body
Multiple statements within curly braces
do-nothing loop
Multiple statements within curly braces
*=
Multiple statements within curly braces
data validation
Multiple statements within curly braces
accumulating
Multiple statements within curly braces
% =
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
61
Why would a loop with altered user input be considered a type of indefinite loop? Give an example.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
62
What would happen if a semicolon is mistakenly placed at the end of a partial statement of a while loop with a Boolean expression and with an empty body?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
63
Explain why an infinite loop might not actually execute infinitely.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
64
How could a programmer identify and escape from an infinite loop?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
65

while(count < getNumberOfEmployees())
Examine the statement above. Write the code that will result in more efficient program execution assuming the result of getNumberOfEmployees() stays the same.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
66
How are indefinite loops used for validating data? Why is a loop structure typically the better choice for validating data than an if statement?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
67
How does a for loop work?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
68
Describe how a loop is controlled by a Boolean expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
69
Provide a code example of a pretest loop and an example of a posttest loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
70
What are some unconventional uses of the three sections inside the parentheses of a  for loop? Show at least three examples using code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
71
What is loop fusion? Write a code segment that uses loop fusion to call two methods, method1 and method2 , 10 times each.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
72
counterLoop = 1;
while(counterLoop < 10);
{
     System.out.println("Hello");
     counterLoop = counterLoop + 1;
}
What is the problem in the above while loop? How would you correct the problem?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
73
public class IncrDemo
{
    public static void main(String[] args)
    {
      int myVal, yourVal;
      myVal = 10;
      System.out.println("My initial value is " + myVal);
      yourVal = ++myVal;
      System.out.println("My new value is " + myVal);
      System.out.println("Your value is " + yourVal):
    }
}
Using the above code, describe how the three println output commands will appear. Explain the values stored in the variables during code execution.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
74
How are nested loops implemented in a loop structure?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
75
while(10 > 1)
{
   System.out.println("This prints forever.");
}
Identify the problem that exists in the above while loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
76
​What are the three sections inside the parentheses of a for loop typically used for?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
77
How could you rewrite the following code to have the arithmetic performed only once, even if the loop executes 1,000 times?
while (x < a + b)
// loop body
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 77 في هذه المجموعة.