Deck 6: Looping

ملء الشاشة (f)
exit full mode
سؤال
An indefinite loop is a(n) ____ loop.

A) counter-controlled
B) event-controlled
C) initialized
D) validating
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
When nesting loops, the variable in the outer loop changes more frequently.
سؤال
A loop controlled by the user is a type of ____ loop.

A) indefinite
B) definite
C) counter-controlled
D) incrementing
سؤال
Which is an infinite loop?

A) loopCount = 5; while(loopCount > 3);
{
System.out.println("Hello");
LoopCount = loopCount - 1;
}
B) loopCount = 1; while(loopCount
{
System.out.println("Hello");
}
C) loopCount = 4; while(loopCount
{
System.out.println("Hello");
LoopCount = loopCount + 1;
}
D) loopCount = 1; while(loopCount
{
System.out.println("Hello");
LoopCount = loopCount + 1;
}
سؤال
A statement that will alter the value of the loop control variable is included in the body of a loop.
سؤال
A loop that never ends is called a(n) ____ loop.

A) definite
B) infinite
C) while
D) for
سؤال
____ is the process of ensuring that a value falls within a specified range.

A) Value checking
B) Data integrity
C) Validating data
D) A range check
سؤال
In order to improve loop performance, it's important to make sure the loop does not include unnecessary operations or statements.
سؤال
Shortcut operators are a programmer's only choice when incrementing or accumulating a variable's value.
سؤال
Making a comparison to 0 is slower than making a comparison to any other value.
سؤال
Altering a variable within both a for statement and within the block it controls can produce errors that are difficult to find.
سؤال
Before entering a loop, the first input statement, or ____, is retrieved.

A) empty body
B) posttest loop
C) loop body
D) priming read
سؤال
On many keyboards, the Break key is also the ____ key.

A) Pause
B) Esc
C) Delete
D) Ctrl
سؤال
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.
سؤال
The statements that make up a loop body will continue to execute as long as the expression value remains false.
سؤال
It is important that the loop control ____ be altered within the body of the loop.

A) value
B) variable
C) constant
D) argument
سؤال
Programmers rarely use indefinite loops when validating input data.
سؤال
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
سؤال
A ____ is a structure that allows repeated execution of a block of statements.

A) body
B) Boolean expression
C) loop
D) loop control
سؤال
Many seasoned programmers start counter values at 1 because they are used to doing so when working with arrays.
سؤال
How many times will outputLabel be called? for(customer = 1; customer
     for(color = 1; color
          outputLabel();

A) 0
B) 3
C) 20
D) 60
سؤال
As long as methods do not depend on one another, ____ 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
سؤال
A(n) ____________________ is a body with no statements in it.
سؤال
If a(n) ____________________ is altered both within the for statement and within the block it controls, it can be very difficult to follow the program's logic.
سؤال
A for loop provides a convenient way to create a(n) ____ loop.

A) counter-controlled
B) posttest
C) while
D) infinite
سؤال
When loops are nested, each pair contains a(n) ____________________ loop and an outer loop.
سؤال
The ____________________ loop is the posttest loop used in Java.
سؤال
You use a unary minus sign preceding a value to make the value ____.

A) negative
B) positive
C) valid
D) constant
سؤال
The process of repeatedly increasing a value by some amount is known as ____.

A) checking
B) adding
C) accumulating
D) containing
سؤال
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
سؤال
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
سؤال
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
سؤال
The order of the conditional expressions in the following is most important within a(n) ____ loop.   while(requestedNum > LIMIT || requestedNum

A) nested
B) posttest
C) pretest
D) indefinite
سؤال
One execution of any loop is called a(n) ____________________.
سؤال
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
سؤال
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
سؤال
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) 8
B) 7
C) 9
D) 10
سؤال
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
سؤال
Match between columns
Operate on two values
block
Operate on two values
loop control variable
Operate on two values
decrementing
Operate on two values
definite loop
Operate on two values
prefix ++
Operate on two values
binary operators
Operate on two values
for loop
Operate on two values
sleep() method
Operate on two values
loop fusion
The technique of combining two loops into one
block
The technique of combining two loops into one
loop control variable
The technique of combining two loops into one
decrementing
The technique of combining two loops into one
definite loop
The technique of combining two loops into one
prefix ++
The technique of combining two loops into one
binary operators
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
loop fusion
Part of the Thread class in the java.lang package
block
Part of the Thread class in the java.lang package
loop control variable
Part of the Thread class in the java.lang package
decrementing
Part of the Thread class in the java.lang package
definite loop
Part of the Thread class in the java.lang package
prefix ++
Part of the Thread class in the java.lang package
binary operators
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
loop fusion
The value that determines whether loop execution continues
block
The value that determines whether loop execution continues
loop control variable
The value that determines whether loop execution continues
decrementing
The value that determines whether loop execution continues
definite loop
The value that determines whether loop execution continues
prefix ++
The value that determines whether loop execution continues
binary operators
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
loop fusion
Multiple statements within curly braces
block
Multiple statements within curly braces
loop control variable
Multiple statements within curly braces
decrementing
Multiple statements within curly braces
definite loop
Multiple statements within curly braces
prefix ++
Multiple statements within curly braces
binary operators
Multiple statements within curly braces
for loop
Multiple statements within curly braces
sleep() method
Multiple statements within curly braces
loop fusion
Within parentheses are three sections separated by exactly two semicolons
block
Within parentheses are three sections separated by exactly two semicolons
loop control variable
Within parentheses are three sections separated by exactly two semicolons
decrementing
Within parentheses are three sections separated by exactly two semicolons
definite loop
Within parentheses are three sections separated by exactly two semicolons
prefix ++
Within parentheses are three sections separated by exactly two semicolons
binary operators
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
loop fusion
A shortcut for incrementing and accumulating
block
A shortcut for incrementing and accumulating
loop control variable
A shortcut for incrementing and accumulating
decrementing
A shortcut for incrementing and accumulating
definite loop
A shortcut for incrementing and accumulating
prefix ++
A shortcut for incrementing and accumulating
binary operators
A shortcut for incrementing and accumulating
for loop
A shortcut for incrementing and accumulating
sleep() method
A shortcut for incrementing and accumulating
loop fusion
A countered loop
block
A countered loop
loop control variable
A countered loop
decrementing
A countered loop
definite loop
A countered loop
prefix ++
A countered loop
binary operators
A countered loop
for loop
A countered loop
sleep() method
A countered loop
loop fusion
Subtracting 1 from a variable
block
Subtracting 1 from a variable
loop control variable
Subtracting 1 from a variable
decrementing
Subtracting 1 from a variable
definite loop
Subtracting 1 from a variable
prefix ++
Subtracting 1 from a variable
binary operators
Subtracting 1 from a variable
for loop
Subtracting 1 from a variable
sleep() method
Subtracting 1 from a variable
loop fusion
سؤال
Create an indefinite while loop that will validate that the loop control variable named userNum is less than the constant MAXVALUE . While true, create a println statement to output "Please enter a higher value". Get user input of another value for userNum after each println statement. Once MAXVALUE is reached, create a final println statement that will output "Max value reached".
سؤال
What are some of the shortcuts Java provides programmers for incrementing and accumulating? Give examples of statements.
سؤال
How could you rewrite the following code to have the arithmetic performed only once, even if the loop executes 1,000 times?
while (x
// loop body
سؤال
How does a for loop work?
سؤال
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?
سؤال
counterLoop = 1;
while(counterLoop
{
     System.out.println("Hello");
     counterLoop = counterLoop + 1;
}
What is the problem in the above while loop? How would you correct the problem?
سؤال
Describe how a loop is controlled by a Boolean expression.
سؤال
Why would a loop with altered user input be considered a type of indefinite loop? Give an example.
سؤال
Provide a code example of a pretest loop and an example of a posttest loop.
سؤال
How could a programmer identify and escape from an infinite loop?
سؤال
What is loop fusion? Write a code segment that uses loop fusion to call two methods, method1 and method2 , 10 times each.
سؤال
  Using the flowchart and code above, describe the execution of the loop. Identify the loop control variable and the value of the variable as the code is executed.<div style=padding-top: 35px>
Using the flowchart and code above, describe the execution of the loop. Identify the loop control variable and the value of the variable as the code is executed.
سؤال
Why would a programmer use curly braces in the body of a do…while loop?
سؤال
What are some unconventional uses of the three sections inside the parentheses of a  for loop? Show at least three examples using code.
سؤال
Write a definite while loop that initializes a loop control variable named decreaseOne to 10 and continues while  decreaseOne > 0. Decrement the loop control variable by 1 and include the println output "Keep going" within the loop.
سؤال
Describe a counter-controlled loop. Explain the process of incrementing and decrementing, and explain the best method for executing a loop a specific number of times.
سؤال
What are the three sections inside the parentheses of a for loop typically used for?
سؤال
Explain why an infinite loop might not actually execute infinitely.
سؤال
How are nested loops implemented in a loop structure?
سؤال
while(count
Examine the statement above. Write the code that will result in more efficient program execution assuming the result of getNumberOfEmployees() stays the same.
سؤال
while(10 > 1)
{
   System.out.println("This prints forever.");
}
Identify the problem that exists in the above while loop.
سؤال
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 indefinite loops used for validating data? Why is a loop structure typically the better choice for validating data than an if statement?
سؤال
  Using the information provided above, write the while loop that will correctly follow the execution of the flowchart.<div style=padding-top: 35px>
Using the information provided above, write the while loop that will correctly follow the execution of the flowchart.
سؤال
public class DoWhileExample
{
    public static void main(String[] args)
    {
int currentValue;
____
____
____
____
____
    }
}
Complete the code above by writing a do…while posttest loop that will output the value of the variable currentValue in a println statement. After the output statement, add a decrement statement to decrease the value of currentValue by 1. Continue the loop until currentValue is equal to 0.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/66
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: Looping
1
An indefinite loop is a(n) ____ loop.

A) counter-controlled
B) event-controlled
C) initialized
D) validating
B
2
When nesting loops, the variable in the outer loop changes more frequently.
False
3
A loop controlled by the user is a type of ____ loop.

A) indefinite
B) definite
C) counter-controlled
D) incrementing
A
4
Which is an infinite loop?

A) loopCount = 5; while(loopCount > 3);
{
System.out.println("Hello");
LoopCount = loopCount - 1;
}
B) loopCount = 1; while(loopCount
{
System.out.println("Hello");
}
C) loopCount = 4; while(loopCount
{
System.out.println("Hello");
LoopCount = loopCount + 1;
}
D) loopCount = 1; while(loopCount
{
System.out.println("Hello");
LoopCount = loopCount + 1;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
5
A statement that will alter the value of the loop control variable is included in the body of a loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
6
A loop that never ends is called a(n) ____ loop.

A) definite
B) infinite
C) while
D) for
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
7
____ is the process of ensuring that a value falls within a specified range.

A) Value checking
B) Data integrity
C) Validating data
D) A range check
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
8
In order to improve loop performance, it's important to make sure the loop does not include unnecessary operations or statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
9
Shortcut operators are a programmer's only choice when incrementing or accumulating a variable's value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
10
Making a comparison to 0 is slower than making a comparison to any other value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
11
Altering a variable within both a for statement and within the block it controls can produce errors that are difficult to find.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
12
Before entering a loop, the first input statement, or ____, is retrieved.

A) empty body
B) posttest loop
C) loop body
D) priming read
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
13
On many keyboards, the Break key is also the ____ key.

A) Pause
B) Esc
C) Delete
D) Ctrl
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
14
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
15
The statements that make up a loop body will continue to execute as long as the expression value remains false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
16
It is important that the loop control ____ be altered within the body of the loop.

A) value
B) variable
C) constant
D) argument
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
17
Programmers rarely use indefinite loops when validating input data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
18
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
19
A ____ is a structure that allows repeated execution of a block of statements.

A) body
B) Boolean expression
C) loop
D) loop control
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
20
Many seasoned programmers start counter values at 1 because they are used to doing so when working with arrays.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
21
How many times will outputLabel be called? for(customer = 1; customer
     for(color = 1; color
          outputLabel();

A) 0
B) 3
C) 20
D) 60
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
22
As long as methods do not depend on one another, ____ 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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
23
A(n) ____________________ is a body with no statements in it.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
24
If a(n) ____________________ is altered both within the for statement and within the block it controls, it can be very difficult to follow the program's logic.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
25
A for loop provides a convenient way to create a(n) ____ loop.

A) counter-controlled
B) posttest
C) while
D) infinite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
26
When loops are nested, each pair contains a(n) ____________________ loop and an outer loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
27
The ____________________ loop is the posttest loop used in Java.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
28
You use a unary minus sign preceding a value to make the value ____.

A) negative
B) positive
C) valid
D) constant
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
29
The process of repeatedly increasing a value by some amount is known as ____.

A) checking
B) adding
C) accumulating
D) containing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
30
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
31
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
32
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
33
A(n) ____ loop is one that performs no actions other than looping.

A) nested
B) do-nothing
C) indefinite
D) posttest
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
34
The order of the conditional expressions in the following is most important within a(n) ____ loop.   while(requestedNum > LIMIT || requestedNum

A) nested
B) posttest
C) pretest
D) indefinite
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
35
One execution of any loop is called a(n) ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
36
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
38
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
39
In the expressions b = 8 and c = --b , what value will be assigned to the variable c ?

A) 8
B) 7
C) 9
D) 10
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
40
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
Operate on two values
block
Operate on two values
loop control variable
Operate on two values
decrementing
Operate on two values
definite loop
Operate on two values
prefix ++
Operate on two values
binary operators
Operate on two values
for loop
Operate on two values
sleep() method
Operate on two values
loop fusion
The technique of combining two loops into one
block
The technique of combining two loops into one
loop control variable
The technique of combining two loops into one
decrementing
The technique of combining two loops into one
definite loop
The technique of combining two loops into one
prefix ++
The technique of combining two loops into one
binary operators
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
loop fusion
Part of the Thread class in the java.lang package
block
Part of the Thread class in the java.lang package
loop control variable
Part of the Thread class in the java.lang package
decrementing
Part of the Thread class in the java.lang package
definite loop
Part of the Thread class in the java.lang package
prefix ++
Part of the Thread class in the java.lang package
binary operators
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
loop fusion
The value that determines whether loop execution continues
block
The value that determines whether loop execution continues
loop control variable
The value that determines whether loop execution continues
decrementing
The value that determines whether loop execution continues
definite loop
The value that determines whether loop execution continues
prefix ++
The value that determines whether loop execution continues
binary operators
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
loop fusion
Multiple statements within curly braces
block
Multiple statements within curly braces
loop control variable
Multiple statements within curly braces
decrementing
Multiple statements within curly braces
definite loop
Multiple statements within curly braces
prefix ++
Multiple statements within curly braces
binary operators
Multiple statements within curly braces
for loop
Multiple statements within curly braces
sleep() method
Multiple statements within curly braces
loop fusion
Within parentheses are three sections separated by exactly two semicolons
block
Within parentheses are three sections separated by exactly two semicolons
loop control variable
Within parentheses are three sections separated by exactly two semicolons
decrementing
Within parentheses are three sections separated by exactly two semicolons
definite loop
Within parentheses are three sections separated by exactly two semicolons
prefix ++
Within parentheses are three sections separated by exactly two semicolons
binary operators
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
loop fusion
A shortcut for incrementing and accumulating
block
A shortcut for incrementing and accumulating
loop control variable
A shortcut for incrementing and accumulating
decrementing
A shortcut for incrementing and accumulating
definite loop
A shortcut for incrementing and accumulating
prefix ++
A shortcut for incrementing and accumulating
binary operators
A shortcut for incrementing and accumulating
for loop
A shortcut for incrementing and accumulating
sleep() method
A shortcut for incrementing and accumulating
loop fusion
A countered loop
block
A countered loop
loop control variable
A countered loop
decrementing
A countered loop
definite loop
A countered loop
prefix ++
A countered loop
binary operators
A countered loop
for loop
A countered loop
sleep() method
A countered loop
loop fusion
Subtracting 1 from a variable
block
Subtracting 1 from a variable
loop control variable
Subtracting 1 from a variable
decrementing
Subtracting 1 from a variable
definite loop
Subtracting 1 from a variable
prefix ++
Subtracting 1 from a variable
binary operators
Subtracting 1 from a variable
for loop
Subtracting 1 from a variable
sleep() method
Subtracting 1 from a variable
loop fusion
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
42
Create an indefinite while loop that will validate that the loop control variable named userNum is less than the constant MAXVALUE . While true, create a println statement to output "Please enter a higher value". Get user input of another value for userNum after each println statement. Once MAXVALUE is reached, create a final println statement that will output "Max value reached".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
43
What are some of the shortcuts Java provides programmers for incrementing and accumulating? Give examples of statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
44
How could you rewrite the following code to have the arithmetic performed only once, even if the loop executes 1,000 times?
while (x
// loop body
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
45
How does a for loop work?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
46
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?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
47
counterLoop = 1;
while(counterLoop
{
     System.out.println("Hello");
     counterLoop = counterLoop + 1;
}
What is the problem in the above while loop? How would you correct the problem?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
48
Describe how a loop is controlled by a Boolean expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
49
Why would a loop with altered user input be considered a type of indefinite loop? Give an example.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
50
Provide a code example of a pretest loop and an example of a posttest loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
51
How could a programmer identify and escape from an infinite loop?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
52
What is loop fusion? Write a code segment that uses loop fusion to call two methods, method1 and method2 , 10 times each.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
53
  Using the flowchart and code above, describe the execution of the loop. Identify the loop control variable and the value of the variable as the code is executed.
Using the flowchart and code above, describe the execution of the loop. Identify the loop control variable and the value of the variable as the code is executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
54
Why would a programmer use curly braces in the body of a do…while loop?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
55
What are some unconventional uses of the three sections inside the parentheses of a  for loop? Show at least three examples using code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
56
Write a definite while loop that initializes a loop control variable named decreaseOne to 10 and continues while  decreaseOne > 0. Decrement the loop control variable by 1 and include the println output "Keep going" within the loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
57
Describe a counter-controlled loop. Explain the process of incrementing and decrementing, and explain the best method for executing a loop a specific number of times.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
58
What are the three sections inside the parentheses of a for loop typically used for?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
59
Explain why an infinite loop might not actually execute infinitely.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
60
How are nested loops implemented in a loop structure?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
61
while(count
Examine the statement above. Write the code that will result in more efficient program execution assuming the result of getNumberOfEmployees() stays the same.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
62
while(10 > 1)
{
   System.out.println("This prints forever.");
}
Identify the problem that exists in the above while loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
63
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
64
How are indefinite loops used for validating data? Why is a loop structure typically the better choice for validating data than an if statement?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
65
  Using the information provided above, write the while loop that will correctly follow the execution of the flowchart.
Using the information provided above, write the while loop that will correctly follow the execution of the flowchart.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
66
public class DoWhileExample
{
    public static void main(String[] args)
    {
int currentValue;
____
____
____
____
____
    }
}
Complete the code above by writing a do…while posttest loop that will output the value of the variable currentValue in a println statement. After the output statement, add a decrement statement to decrease the value of currentValue by 1. Continue the loop until currentValue is equal to 0.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 66 في هذه المجموعة.