Filters
Question type

Study Flashcards

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

E) B) and C)
F) B) and D)

Correct Answer

verifed

verified

A for loop provides a convenient way to create a(n) ____ loop.


A) counter-controlled
B) posttest
C) while
D) infinite

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

Match each term with the correct statement below.

Premises
Operate on two values
The technique of combining two loops into one
Part of the Thread class in the java.lang package
The value that determines whether loop execution continues
Multiple statements within curly braces
Within parentheses are three sections separated by exactly two semicolons
A shortcut for incrementing and accumulating
A countered loop
Subtracting 1 from a variable
Responses
for loop
decrementing
loop control variable
loop fusion
sleep() method
block
binary operators
prefix ++
definite loop

Correct Answer

Operate on two values
binary operators
The technique of combining two loops into one
loop fusion
Part of the Thread class in the java.lang package
sleep() method
The value that determines whether loop execution continues
loop control variable
Multiple statements within curly braces
block
Within parentheses are three sections separated by exactly two semicolons
for loop
A shortcut for incrementing and accumulating
prefix ++
A countered loop
definite loop
Subtracting 1 from a variable
decrementing

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

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

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

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

A loop controlled by the user is a type of ____ loop.


A) indefinite
B) definite
C) counter-controlled
D) incrementing

E) B) and C)
F) All of the above

Correct Answer

verifed

verified

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.

Correct Answer

verifed

verified

numEmployees = getNu...

View Answer

A statement that will alter the value of the loop control variable is included in the body of a loop.

A) True
B) False

Correct Answer

verifed

verified

A ____ is a structure that allows repeated execution of a block of statements.


A) body
B) Boolean expression
C) loop
D) loop control

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

Altering a variable within both a for statement and within the block it controls can produce errors that are difficult to find.

A) True
B) False

Correct Answer

verifed

verified

The statements that make up a loop body will continue to execute as long as the expression value remains false.

A) True
B) False

Correct Answer

verifed

verified

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;
}

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

Before entering a loop, the first input statement, or ____, is retrieved.


A) empty body
B) posttest loop
C) loop body
D) priming read

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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?

Correct Answer

verifed

verified

If a semicolon is mistakenly placed at t...

View Answer

Why would a loop with altered user input be considered a type of indefinite loop? Give an example.

Correct Answer

verifed

verified

An event-controlled loop is a type of in...

View Answer

In order to improve loop performance, it's important to make sure the loop does not include unnecessary operations or statements.

A) True
B) False

Correct Answer

verifed

verified

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

E) All of the above
F) A) and D)

Correct Answer

verifed

verified

D

It is important that the loop control ____ be altered within the body of the loop.


A) value
B) variable
C) constant
D) argument

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

B

How could a programmer identify and escape from an infinite loop?

Correct Answer

verifed

verified

You might suspect an infinite loop if th...

View Answer

____ 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

E) A) and C)
F) None of the above

Correct Answer

verifed

verified

Showing 1 - 20 of 66

Related Exams

Show Answer