Deck 4: Introduction to Control Statements

Full screen (f)
exit full mode
Question
Some programmers prefer to use for loops instead of while loops because the loop control variable can be declared in its header. ____________________
Use Space or
up arrow
down arrow
to flip the card.
Question
Use an if statement to instruct a program to execute one statement if the condition is true, and another if the condition is false.
Question
Because it returns a value of true or false, the condition in an if statement must be a(n) ____ expression.

A) Boolean
B) control
C) else
D) entry-controlled
Question
An off-by-one error occurs when the value returned is one more or less than the expected result.
Question
When a program responds more slowly than expected, it is reasonable to assume that it is stuck in an overloading loop. ____________________
Question
____ must always occur in pairs.

A) Semicolons
B) Conditions
C) Statements
D) Braces
Question
A program that controls how many times a loop is executed is called a task-controlled loop. ____________________
Question
m++ and m = m + 1 are the same thing.
Question
____ is when the same name is used for two different methods.

A) Infinite loop
B) Overloading
C) Iteration
D) Sentinel
Question
In a while statement, if the condition is false from the outset, the statement(s) inside the loop never execute.
Question
A program can output data to a file.
Question
In a for statement, the counter is updated at the top of the loop.
Question
It is better to underuse braces or parentheses than to overuse them.
Question
FIGURE 4-1 FIGURE 4-1   Figure 4-1 above is an example of a flowchart. _________________________<div style=padding-top: 35px>
Figure 4-1 above is an example of a flowchart. _________________________
Question
A program used to simulate coin toss results uses a random number generator.
Question
For a loop to terminate, each pass must move the variables in the condition significantly closer to satisfying the condition.
Question
In Java, while and if-else are examples of conditional statements. ____________________
Question
An if-else statement is commonly used to check user inputs for validity before processing them.
Question
The decrement operator is ____.

A) --
B) ++
C) /
D) !=
Question
If a method's signature is labeled ____, the message is sent to the method's class instead of to an object.

A) class
B) iterative
C) static
D) count-controlled
Question
In a text file, numeric data can be separated by any of the following EXCEPT ____.

A) return
B) space
C) tab
D) newline
Question
Data can be output to a text file using the class ____.

A) Scanner
B) WriteData
C) PrintWriter
D) TextFile
Question
Carter thinks his program is stuck in an infinite loop. What should he do to his PC to make it stop?

A) Unplug the computer.
B) Press Ctrl+C.
C) Press Ctrl+Alt+Delete.
D) Restart the computer.
Question
Gabrielle is using a text file to input the list of numbers. Which of the following is NOT true?

A) If the file is missing, the JVM will thrown an I/O exception.
B) The numbers must be separated by whitespace characters.
C) Gabrielle uses the PrintWriter class to read the data in the text file.
D) The text file must contain a special character that marks the end of the file.
Question
An I/O exception is in the category of ____ exceptions.

A) thrown
B) checked
C) run-time
D) overloading
Question
The ____________________ operator decreases a variable's value by one.
Question
A(n) ____ is a special value that marks the end of a list.

A) break
B) sentinel
C) counter
D) iteration
Question
In a(n) ____-controlled loop, the continuation condition is tested at the top of the loop on each pass.

A) task
B) entry
C) count
D) All of the above
Question
A(n) ____ is a small window that asks for information, and includes a text field and command buttons.

A) panel
B) message dialog box
C) task pane
D) input dialog box
Question
The ____ statement is used to write count-controlled loops.

A) for
B) number
C) cntr
D) if-else
Question
The____ operator means not equal to.

A) --
B) = =
C) <=
D) !=
Question
The presence or absence of the ____ symbol(s) can seriously affect the logic of a selection statement.

A) { }
B) //
C) ;
D) /* */
Question
Which of the following is true about using a text file for input?

A) The data set can be much larger.
B) Data can be input faster and with less chance of error.
C) Data can be used repeatedly with the same program or with different programs.
D) All of the above are true.
Question
Use a(n) ____ statement rather than two if statements when the alternative courses of action are mutually exclusive.

A) while
B) for
C) if-else
D) whether
Question
A loop that continues until something specific is accomplished is called a(n) ____-controlled loop.

A) count
B) entry
C) task
D) outcome
Question
FIGURE 4-2 <strong>FIGURE 4-2   Figure 4-2 above represents the behavior of a(n) ____ statement.</strong> A) if-else B) while C) random D) infinite <div style=padding-top: 35px>
Figure 4-2 above represents the behavior of a(n) ____ statement.

A) if-else
B) while
C) random
D) infinite
Question
To get out of a loop prematurely, use a(n) ____ statement.

A) exit
B) false
C) break
D) then
Question
A typical loop has four component parts, including all of the following EXCEPT ___ statements.

A) initializing
B) body
C) update
D) verification
Question
Each pass through a loop is called a(n) ____________________.
Question
The ____________________ operator increases a variable's value by one.
Question
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
What happens when a program encounters an operation that it cannot perform at runtime.
Question
____________________ statements execute within each pass and implement the calculation in question.
Question
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
A statement that changes the values of the variables tested in the termination condition.
Question
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
Exits a loop before the condition is false.
Question
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
A method in the Math class.
Question
A(n) ____________________ control statement is located inside another control statement.
Question
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
A class used to simulate stock market fluctuations.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/47
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 4: Introduction to Control Statements
1
Some programmers prefer to use for loops instead of while loops because the loop control variable can be declared in its header. ____________________
True
2
Use an if statement to instruct a program to execute one statement if the condition is true, and another if the condition is false.
False
3
Because it returns a value of true or false, the condition in an if statement must be a(n) ____ expression.

A) Boolean
B) control
C) else
D) entry-controlled
A
4
An off-by-one error occurs when the value returned is one more or less than the expected result.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
5
When a program responds more slowly than expected, it is reasonable to assume that it is stuck in an overloading loop. ____________________
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
6
____ must always occur in pairs.

A) Semicolons
B) Conditions
C) Statements
D) Braces
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
7
A program that controls how many times a loop is executed is called a task-controlled loop. ____________________
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
8
m++ and m = m + 1 are the same thing.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
9
____ is when the same name is used for two different methods.

A) Infinite loop
B) Overloading
C) Iteration
D) Sentinel
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
10
In a while statement, if the condition is false from the outset, the statement(s) inside the loop never execute.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
11
A program can output data to a file.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
12
In a for statement, the counter is updated at the top of the loop.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
13
It is better to underuse braces or parentheses than to overuse them.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
14
FIGURE 4-1 FIGURE 4-1   Figure 4-1 above is an example of a flowchart. _________________________
Figure 4-1 above is an example of a flowchart. _________________________
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
15
A program used to simulate coin toss results uses a random number generator.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
16
For a loop to terminate, each pass must move the variables in the condition significantly closer to satisfying the condition.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
17
In Java, while and if-else are examples of conditional statements. ____________________
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
18
An if-else statement is commonly used to check user inputs for validity before processing them.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
19
The decrement operator is ____.

A) --
B) ++
C) /
D) !=
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
20
If a method's signature is labeled ____, the message is sent to the method's class instead of to an object.

A) class
B) iterative
C) static
D) count-controlled
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
21
In a text file, numeric data can be separated by any of the following EXCEPT ____.

A) return
B) space
C) tab
D) newline
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
22
Data can be output to a text file using the class ____.

A) Scanner
B) WriteData
C) PrintWriter
D) TextFile
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
23
Carter thinks his program is stuck in an infinite loop. What should he do to his PC to make it stop?

A) Unplug the computer.
B) Press Ctrl+C.
C) Press Ctrl+Alt+Delete.
D) Restart the computer.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
24
Gabrielle is using a text file to input the list of numbers. Which of the following is NOT true?

A) If the file is missing, the JVM will thrown an I/O exception.
B) The numbers must be separated by whitespace characters.
C) Gabrielle uses the PrintWriter class to read the data in the text file.
D) The text file must contain a special character that marks the end of the file.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
25
An I/O exception is in the category of ____ exceptions.

A) thrown
B) checked
C) run-time
D) overloading
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
26
The ____________________ operator decreases a variable's value by one.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
27
A(n) ____ is a special value that marks the end of a list.

A) break
B) sentinel
C) counter
D) iteration
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
28
In a(n) ____-controlled loop, the continuation condition is tested at the top of the loop on each pass.

A) task
B) entry
C) count
D) All of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
29
A(n) ____ is a small window that asks for information, and includes a text field and command buttons.

A) panel
B) message dialog box
C) task pane
D) input dialog box
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
30
The ____ statement is used to write count-controlled loops.

A) for
B) number
C) cntr
D) if-else
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
31
The____ operator means not equal to.

A) --
B) = =
C) <=
D) !=
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
32
The presence or absence of the ____ symbol(s) can seriously affect the logic of a selection statement.

A) { }
B) //
C) ;
D) /* */
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following is true about using a text file for input?

A) The data set can be much larger.
B) Data can be input faster and with less chance of error.
C) Data can be used repeatedly with the same program or with different programs.
D) All of the above are true.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
34
Use a(n) ____ statement rather than two if statements when the alternative courses of action are mutually exclusive.

A) while
B) for
C) if-else
D) whether
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
35
A loop that continues until something specific is accomplished is called a(n) ____-controlled loop.

A) count
B) entry
C) task
D) outcome
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
36
FIGURE 4-2 <strong>FIGURE 4-2   Figure 4-2 above represents the behavior of a(n) ____ statement.</strong> A) if-else B) while C) random D) infinite
Figure 4-2 above represents the behavior of a(n) ____ statement.

A) if-else
B) while
C) random
D) infinite
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
37
To get out of a loop prematurely, use a(n) ____ statement.

A) exit
B) false
C) break
D) then
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
38
A typical loop has four component parts, including all of the following EXCEPT ___ statements.

A) initializing
B) body
C) update
D) verification
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
39
Each pass through a loop is called a(n) ____________________.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
40
The ____________________ operator increases a variable's value by one.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
41
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
What happens when a program encounters an operation that it cannot perform at runtime.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
42
____________________ statements execute within each pass and implement the calculation in question.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
43
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
A statement that changes the values of the variables tested in the termination condition.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
44
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
Exits a loop before the condition is false.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
45
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
A method in the Math class.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
46
A(n) ____________________ control statement is located inside another control statement.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
47
Identify the letter of the choice that best matches the phrase or definition.
a.Random
b.Update
c.Abs
d.Exception
e.Break
A class used to simulate stock market fluctuations.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 47 flashcards in this deck.