1Logical errors are mistakes that cause the program to produce erroneous results.
True or False
True
2The original name for Java was
Elm
HotJava
Oak
JavaScript
Oak
3What is syntax?
the words or characters that are defined by the programmer
the symbols or words that perform operations in a program
the words that have a special meaning in the programming language
the rules that must be followed when writing a program
the rules that must be followed when writing a program
4There are __________ bits in a byte.
4
8
16
32
8
5Without programmers, the users of computers would have no software, and, without software, computers would not be able to do anything.
True or False
True
6These are words that have a special meaning in the programming language.
punctuation
key words
operators
programmer-defined names
key words
7The computer is a tool used by so many professionals that it cannot be easily categorized.
True or False
True
8The end of a Java statement is indicated by a ________.
bracket (})
asterisk (*)
semicolon (;)
colon (:)
semicolon (;)
9Computer programming is
an art
a science
neither of the above
both of the above
both of the above
10A procedure is a set of programming language statements that, together, perform a specific task.
True
False
True
11The Java compiler generates
machine code
source code
byte code
HTML
byte code
12These are the rules that must be followed when writing a program
key words
syntax
punctuation
operators
syntax
13JVM stands for
Java Virtual Method
Java Variable Method
Java Variable Machine
Java Virtual Machine
Java Variable Machine
14Validating the results of a program is important to
create a model of the program
correct runtime errors
make sure the program solves the original problem
correct syntax error
make sure the program solves the original problem
15A cross between human language and a programming language is called
the Java language
the Java Virtual Machine
a compiler
pseudocode
pseudocode
16The Java Virtual Machine is a program that reads Java byte code instructions and executes them as they are read.
True
False
True
17Which of the following will run the compiled program called ReadIt?
java ReadIt
run ReadIt
go ReadIt
java ReadIt.java
java ReadIt
18The central processing unit (CPU) consists of two parts which are
the input and output devices
the control unit and the arithmetic and logic unit (ALU)
the arithmetic and logic unit (ALU) and main memory
the control unit and main memory
the control unit and the arithmetic and logic unit (ALU)
19Byte code instructions are
machine code instructions
syntax errors
another name for source code
read and interpreted by the JVM
read and interpreted by the JVM
20Which of the following will compile a program called ReadIt?
java ReadIt.java
javac ReadIt.java
javac ReadIt.javac
java ReadIt.javac
javac ReadIt.java
21Software refers to
firmware
programs
the physical components a computer is made of
data stored in RAM
programs
22Each byte is assigned a unique number known as an address
True
False
True
23A solid-state drive has no moving parts and operates faster than a traditional disk drive.
True
False
True
24Application software refers to
key words
pseudocode
the operating system
the programs that make the computer useful to the user
the programs that make the computer useful to the user
25Because Java byte code is the same on all computers, compiled Java programs
must be re-compiled for each different machine before they can be run
are highly portable
cannot run on computers with different operating systems
are nonexistent
are highly portable
26Key words are
symbols or words that perform operations on one or more operands
words or characters representing values that are defined by the programmer
words that have a special meaning in the programming language
the data names in your program
words that have a special meaning in the programming language
27Each different type of CPU has its own
syntax
firmware
machine language
software
machine language
28Internally, the central processing unit (CPU) consists of two parts which are __________
the input and output devices
the control unit and the arithmetic/logic unit (ALU)
the control unit and main memory
the arithmetic/logic unit (ALU) and main memory
the control unit and the arithmetic/logic unit (ALU)
29Byte code instructions are
another name for source code
machine code instructions
syntax errors
read and interpreted by the JVM
read and interpreted by the JVM
30These are symbols or words that perform operations on one or more operands.
programmer-defined names
operators
punctuation
key words
operators
31Encapsulation refers to the combining of data and code into a single object.
True
False
True
32These characters serve specific purposes, such as marking the beginning or ending of a statement, or separating items in a list
programmer-defined names
key words
punctuation
operators
punctuation
33Each byte is assigned a unique
Bit
address
CPU
Variable
address
34Java was developed by
Sun Microsystems
IBM
Microsoft
Hewlett-Packard
Sun Microsystems
35A characteristic of __________ is that only an object's methods are able to directly access and make changes to an object's data.
component reusability
procedures
classes
data hiding
data hiding
36Colons are used to indicate the end of a Java statement.
True
False
False
37Java source files end with the .class extension.
True
False
False
38A runtime error is usually the result of
a logical error
a syntax error
a compiler error
bad data
a logical error
39Java source files end with the .class extension.
True
False
False
40RAM is usually
a static type of memory, used for permanent storage
an input/output device
secondary storage
a volatile type of memory, used for temporary storage
a volatile type of memory, used for temporary storage
41One type of design tool used by programmers when creating a model of a program is
syntax
pseudocode
byte code
the ALU
pseudocode
42__________ refers to the physical components that a computer is made of.
Software
The system
The device
Hardware
Hardware
43A byte is made up of eight
variables
CPUs
bits
addresses
bits
44When an object's internal data is hidden from outside code and access to that data is restricted to the object's methods, the data is protected from accidental corruption.
True
False
False
45A(n) __________ is a software entity that contains data and procedures.
object
method
class
program
object
46Computers can do many different jobs because they are
automated
reliable
programmable
electronic
programmable
47A computer program is
the same as main memory
a set of instructions that allow the computer to solve a problem or perform a task
another name for an operating system
only used for desktop computers
a set of instructions that allow the computer to solve a problem or perform a task
48Application software refers to programs that make the computer useful to the user
True
False
True
49Compiled byte code is also called source code.
True
False
False
50Which of the following is a software entity that contains data and procedures?
a method
a class
a program
an object
an object
51__________ refers to the physical components that a computer is made of.
Input
Main memory
Control unit
Hardware
Hardware
52Which of the following is not one of the major components of a typical computer system?
input/output devices
All of the above are major components
the CPU
main memory
secondary storage devices
All of the above are major components
53These are words or names that are used to identify storage locations in memory and parts of the program that are created by the programmer
operators
programmer-defined names
punctuation
key words
programmer-defined names
54While __________ is centered on creating procedures, __________ is centered on creating objects.
routine programming, method programming
object-oriented programming, procedural programming
procedural programming, class programming
procedural programming, object-oriented programming
procedural programming, object-oriented programming
55A(n) __________ is used to write computer programs.
application
programming language
operating system
pseudocode document
programming language
56If you were to look at a machine language program, you would see
circuits
a stream of binary numbers
Java source code
English words
a stream of binary numbers
57This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some outcome or resultant information.
input device
Memory
Secondary storage
CPU
CPU
58Variables are
operators that perform operations on one or more operands
reserved words
symbolic names made up by the programmer that represent memory locations
symbolic names made up by the programmer and once created, their values cannot be changed
symbolic names made up by the programmer that represent memory locations
59This is a named storage location in the computer’s memory
operator
key word
class
variable
variable
60The contents of a variable cannot be changed while the program is running.
True
False
False
61Which of the following is not part of the programming process?
testing and debugging
entering code and compiling it
defining and modeling the problem
All of these are parts of the programming process
All of these are parts of the programming process
62A set of programming language statements that perform a specific task is a(n)
object
source code
procedure
pseudocode chart
procedure
63The two primary methods of programming in use today are
practical and theoretical
hardware and software
procedural and object-oriented
desktop and mobile
procedural and object-oriented
64An object typically hides its data but allows outside code access to
private data members
the pseudocode
the data files
the methods that operate on the data
the methods that operate on the data
65A program is a sequence of instructions stored in
software
firmware
the computer's memory
the CPU
the computer's memory
66This type of memory can hold data for long periods of time—even when there is no power to the computer.
RAM
CPU storage
primary storage
secondary storage
secondary storage
67Which of the following are not valid println statements? (Indicate all that apply.)
System.out.println("Have a nice day");
out.System.println(value);
println.out(Programming is great fun);
System.out.println + "Hello World";
out.System.println(value);
println.out(Programming is great fun);
System.out.println + "Hello World";
68Java is not case sensitive.
False
True
False
69Which of the following statements correctly creates a Scanner object for keyboard input?
Keyboard scanner = new Keyboard(System.in);
Scanner kbd = new Scanner(System.keyboard);
Scanner keyboard = new Scanner(System.in);
Scanner keyboard(System.in);
Scanner keyboard = new Scanner(System.in);
70The System.out.printf method allows you to format output in a variety of ways.
True
False
True
71Which of the following are not valid assignment statements? (Indicate all that apply.)
letter = 'W';
total = 9;
profit = 129
72 = amount;
profit = 129
72 = amount;
72A variable must be declared before it can be used.
True
False
True
73The primitive data types only allow a(n) ____ to hold a single value.
class
literal
object
variable
variable
74Which of the following is not a primitive data type?
short
long
float
string
string
75The boolean data type may contain which of the following range of values?
-32,768 to +32,767
-128 to + 127
-2,147,483,648 to +2,147,483,647
true or false
true or false
76If one of an operator’s operands is a double, and the other operand is an int, Java will automatically convert the value of the double to an int.
True
False
False
77Which of the following statements will correctly convert the data type, if x is a float and y is a double?
x = (float)y;
x = y;
x = float y;
x = y;
x = (float)y;
78A Java source file must be saved with the extension
.java
.javac
.src
.class
.java
79Which Scanner class method would you use to read a string as input?
nextLine
nextString
getLine
readString
nextLine
80This type of operator lets you manually convert a value, even if it means that a narrowing conversion will take place.
uploading
cast
binary
dot
cast
81When you call one of the Scanner class’s methods to read a primitive value, such as nextInt or nextDouble, and then call the nextLine method to read a string, an annoying and hard-to-find problem can occur.
True
False
True
82Which of the following cannot be used as identifiers in Java?
class names
variable names
key words
objects
key words
83A variable’s scope is the part of the program that has access to that variable.
True
False
True
84To display the output on the next line, you can use the println method or use the ____ escape sequence in the print method)
\t
\n
\n
85You cannot change the value of a variable whose declaration uses the final key word.
True
False
True
86Which of the following statements is invalid?
double r = 326.75;
double r = 2.9X106;
double r = 9.4632E15;
double r = 9.4632e15;
double r = 2.9X106;
87Which of the following is not a rule that must be followed when naming identifiers?
Uppercase and lowercase characters are distinct.
The first character must be one of the letters a-z, A-Z, and underscore or a dollar sign.
Identifiers can contain spaces.
After the first character, you may use the letters a-z, A-Z, the underscore, a dollar sign, or digits 0-9.
Identifiers can contain spaces.
88The Java API provides a class named Math that contains numerous methods which are useful for performing complex mathematical operations.
False
True
True
89What would be displayed as a result of executing the following code?
final int x = 22, y = 4;
y += x;
System.out.println("x = " + x + ", y = " + y);
x = 22, y = 26
x = 22, y = 88
x = 22, y = 4
Nothing. There is an error in the code.
Nothing. There is an error in the code.
90To print “Hello, world” on the monitor, which of the following Java statements should be used?
system.out.println(Hello, world);
SystemOutPrintln(‘Hello, world’);
System.out.println(“Hello, world”);
System Print = “Hello, world”;
System.out.println(“Hello, world”);
91Variable names may begin with a number.
True
False
False
92Comments that begin with // can be processed by javadoc.
True
False
False
93When Java converts a lower-ranked value to a higher-ranked type, it is called a(n) .
escalating conversion
4-bit conversion
narrowing conversion
widening conversion
widening conversion
94Which of the following would contain the translated Java byte code for a program named Demo?
Demo.class
Demo.byte
Demo.code
Demo.java
Demo.class
95What is the value of z after the following code is executed?
int x = 5, y = 28;
float z;
z = (float) (y / x);
5.60
3.0
5.6
5.0
5.0
96Class names and key words are examples of variables.
False
True
False
97You can use this class to display dialog boxes.
InputStreamReader
DialogBox
BufferedReader
JOptionPane
JOptionPane
98This key word is used to declare a named constant.
final
namedConstant
concrete
constant
final
99A left brace in a Java program is always followed by a right brace later in the program.
True
False
True
100Character literals are enclosed in _ and string literals are enclosed in _.
double quotes, single quotes
single quotes, single quotes
double quotes, double quotes
single quotes, double quotes
single quotes, double quotes
101Programming style includes techniques for consistently putting spaces and indentation in a program to help create visual cues.
False
True
True
102Which of the following is a named storage location in the computer’s memory?
an operator
a variable
a literal
a constant
a variable
103To compile a program named First you would use which of the following commands?
compile First.javac
java First.java
javac First
javac First.java
javac First.java
104These characters mark the beginning of a documentation comment.
*
//
*/
*
105Named constants are initialized with a value and that value cannot change during the execution of the program.
False
True
True
106A group of statements, such as the contents of a class or a method, are enclosed in
brackets []
parentheses ()
any of these will do
braces {}
braces {}
107The following data (72, 'A', "Hello World", 2.8712) are all examples of
literals
strings
none of these
variables
literals
108What is the value of z after the following statements have been executed?
int x = 4, y = 33;
double z;
z = (double) (y / x);
8.25
0
4
8.0
8.0
109A Java program must have at least one of the following:
a class definition
a System.out.println(); statement
a variable declaration
a comment
a class definition
110If x has been declared an int, which of the following statements is invalid?
x = -59832;
x = 0;
x = 1,000;
x = 592
x = 1,000;
111Variables are classified according to their
locations
values
data types
names
data types
112Both character and string literals can be assigned to a char variable.
True
False
False
113Which Scanner class method reads a String?
nextLine
getLine
charAt
nextString
nextLine
114Every Java application program must have
at least two data types
a class named MAIN
integer variables
a method named main
a method named main
115Every complete statement ends with a .
period
ending brace
parenthesis
semicolon
semicolon
116The negation operator is .
none of these
ternary
binary
unary
unary
117A value that is written into the code of a program is a(n) ____.
operator
literal
variable
assignment statement
literal
118These characters mark the beginning of a multi-line comment.
//
*/
*
119These characters mark the beginning of a single-line comment.
*
//
*/
//
120Which of the following is not a valid Java comment?
Comment one /
/ Comment four /
// Comment three
/ Comment two /
/ Comment two /
121In the following Java statement, what value is stored in the variable name? String name = “John Doe”;
“name”
John Doe
the memory address where “John Doe” is located
the memory address where name is located
the memory address where “John Doe” is located
122When the + operator is used with strings, it is known as the
addition operator
string concatenation operator
combines assignment operator
assignment operator
string concatenation operator
123Which of the following is a value that is written into the code of a program?
an assignment statement
an operator
a variable
a literal
a literal
124If the compiler encounters a statement that uses a variable before the variable is declared, an error will result.
True
False
True
125What is the result of the following expression? 10 + 5 * 3 - 20
-5
25
-50
5
5
126In Java, ____ must be declared before they can be used)
literals
variables
key words
comments
variables
127What is the result of the following expression? 17 % 3 * 2 - 12 + 15
7
105
12
8
7
128A Java program will not compile unless it contains the correct line numbers.
False
True
False
129Which Scanner class method would you use to read a double as input?
nextDouble
readDouble
None of these; you cannot read a double with the Scanner class
getDouble
nextDouble
130What output will be displayed as a result of executing the following code?
int x = 5, y = 20;
x += 32;
y /= 4;
System.out.println("x = " + x + ", y = " + y);
x = 9, y = 52
x = 160, y = 80
x = 37, y = 5
x = 32, y = 4
x = 37, y = 5
131Variables of the boolean data type are useful for
working with very large integers
evaluating scientific notation
evaluating conditions that are either true or false
working with small integers
evaluating conditions that are either true or false
132All lines in a conditionally executed block should be indented one level.
False
True
True
133Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?
str1.equalsIgnoreCase(str2)
str1 != str2
str1.equalsInsensitive(str2)
str1 || str2
str1.equalsIgnoreCase(str2)
134The String.format method works exactly like the System.out.printf method, except that it does not display the formatted string on the screen.
False
True
True
135This determines whether two different String objects contain the same string.
the = operator
the equals method
the stringCompare method
the == operator
the equals method
136What would be the value of discountRate after the following statements are executed?
.03
.01
0
.05

.01
137The ____ statement is used to create a decision structure which allows a program to have more than one path of execution.
if
block
null
flag
if
138Which of the following is the correct boolean expression to test for: int x being a value between, but not including, 500 and 650, or int y not equal to 1000?
((x > 500 && x < 650) || (y != 1000))
((x > 500 AND x < 650) OR !(y.equal(1000)))
((x < 500 && x > 650) || !(y == 1000))
((x >= 500 && x <= 650) && (y != 1000))
((x > 500 && x < 650) || (y != 1000))
139An else clause always goes with _____ .
the if clause that is randomly selected by the compiler
the closest if clause
the closest previous if clause that doesn’t already have its own else clause
none of these
the closest previous if clause that doesn’t already have its own else clause
140Which of the following will format 12.78 to display as 12.8%?
System.out.printf(“%.2f%%”, 12.78);
System.out.printf(“%1.2d%”, 12.78);
System.out.printf(“%.1f%%”, 12.78);
System.out.printf(“%2.1d%”, 12.78);
System.out.printf(“%.1f%%”, 12.78);
141What will be the value of discountRate after the following statements are executed?
0.08
0.06
0.0
0.04

0.0
142The System.out.printf method formats a string and displays it in the console window.
True
False
True
143How does the character ‘A’ compare to the character ‘B’?
‘A’ is less than ‘B’
‘A’ is equal to ‘B’
You cannot compare characters
‘A’ is greater than ‘B’
A’ is less than ‘B’
144The conditional operator takes this many operands.
three
two
one
four
three
145What will be the values of ans, x, and y after the following statements are executed?
ans = 45, x = 50, y = 50
ans = 60, x = 0, y = 50
ans = 45, x = 50, y = 0
ans = 60, x = 50, y = 100

ans = 60, x = 0, y = 50
146To create a block of statements, you enclose the statements in these.
angled brackets <>
square brackets []
parentheses()
braces {}
braces {}
147What will be the value of pay after the following statements are executed?
400.00
475.00
450.00
465.00

475.00
148This is an empty statement that does nothing.
null statement
conditional statement
virtual statement
missing statement
null statement
149&&, ||, and ! are _____ .
logical operators
ternary operators
conditional operators
relational operators
logical operators
150In an if-else statement, if the boolean expression is false then
the first statement or block is executed
no statements or blocks are executed
all the statements or blocks are executed
the statement or block following the else is executed
the statement or block following the else is executed
151A ____ is a boolean variable that signals when some condition exists in the program.
flag
sentinel
block
case
flag
152What would be the value of bonus after the following statements are executed?
1500
1000
2000
1250

1000
153If you prematurely terminate an if statement with a semicolon, the compiler will
not display an error message
none of these
both (a) and (b)
assume you are placing a null statement there
both (a) and (b)
154This is an if statement that appears inside another if statement.
tiered if statement
structured if statement
nested if statement
dislodged if statement
nested if statement
155What will be displayed after the following statements are executed?
The code contains an error and will not compile.
10
120
100

120
156In a switch statement, if two different values for the CaseExpression would result in the same code being executed, you must have two copies of the code, one after each CaseExpression.
True
False
False
157What will be printed when the following code is executed?
0,045,678.26
45678.259
45,678.3
45,678.26

45,678.26
158“When an if statement is nested in the if clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true.
True
False
True
159The boolean expression in an if statement must evaluate to
positive or negative
left or right
true or false
degrees or radians
true or false
160The scope of a variable is limited to the block in which it is defined.
False
True
True
161What is the value of charges after the following code has been executed?
14.00
28.00
21.00
7.00

21.00
162When an if statement is nested in the else clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true.
True
False
False
163Java requires that the boolean expression being tested by an if statement be enclosed in
a set of double quotes
a set of braces
a set of brackets
a set of parentheses
a set of parentheses
164A conditionally executed statement should be indented one level from the if clause.
False
True
True
165This section of a switch statement is branched to if none of the case expressions match the switch expression.
otherwise
else
default
case
default
166You can use this method to display formatted output in a console window.
System.out.formatted
Console.format
System.out.printf
Format.out.println
System.out.printf
167Which of the following expressions determines whether the char variable, chrA, is not equal to the letter ‘A’?
chrA != ‘A’
chrA || ‘A’
chrA.notEquals(A)
chrA == ‘A’
chrA != ‘A’
168All it takes for an AND expression to be true is for one of the subexpressions to be true.
True
False
False
169The switch statement is a
nested decision structure
test expression
sequence structure
multiple alternative decision structure
multiple alternative decision structure
170What will be the value of bonus after the following statements are executed?
1000
500
750
1250

1000
171>, <, and == are _____ .
ternary operators
logical operators
relational operators
conditional operators
relational operators
172What will be the value of ans after the following statements are executed?
30
80
The code contains an error and will not compile.
50

The code contains an error and will not compile.
173Which of the following is the not equal operator?
*&
NOT
!=
<>
!=
174This is a boolean variable that signals when some condition exists in the program.
sentinel
flag
signal
siren
flag
175A block of code is enclosed in a set of
brackets, [ ]
braces, { }
double quotes, ” “
parentheses, ( )
braces, { }
176If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?
str1.equals(str2)
str1 && str2
str1 += str2
str1 = str2
str1.equals(str2)
177What does the following code display?
%9 %12
9 12
%d %d
%d 9

9 12
178__ works like this: If the expression on the left side of the && operator is false, the expression the right side will not be checked.
relational evaluation
Boolean logic
reverse logic
short-circuit evaluation
short-circuit evaluation
179Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)?
if (temp > 0 && temp < 100)
if (temp >= 0 && temp <= 100)
if (temp > 0 || temp < 100)
if (temp >= 0 || temp <= 100)
if (temp >= 0 && temp <= 100)
180An expression tested by an if statement must evaluate to
0 or 1
true or false
t or f
+1 or -1
true or false
181In a switch statement, each of the case values must be unique.
True
False
True
182In Java, when a character is stored in memory, it is actually the ____ that is stored.
Unicode number
floating-point value
letter, symbol, or number
ASCII code
Unicode number
183Which of the following will format 12.7801 to display as $12.78?
System.out.printf(“%.2f$$”, 12.7801);
System.out.printf(“$%,.2f”, 12.7801);
System.out.printf(“%f”, 12.7801);
System.out.printf(“$d”, 12.7801);
System.out.printf(“$%,.2f”, 12.7801);
184When testing for character values, the switch statement does not test for the case of the character.
False
True
False
185A flag may have the values
of any range of integers
defined or undefined
of any Unicode character
true or false
true or false
186Which of the following is the correct boolean expression to test for: int x being a value less than or equal to 500 or greater than 650, or int y not equal to 1000?
((x >= 500 && x < 650) && (y != 1000))
((x <= 500 || x > 650) && !(y == 1000))
((x >= 500 || x < 650) || (y != 1000))
((x <= 500 OR x > 650) AND !(y.equal(1000)))
((x <= 500 || x > 650) && !(y == 1000))
187A local variable’s scope always ends at the closing brace of the block of code in which it is declared.
False
True
True
188When two strings are compared using the String class’s compareTo method, the comparison is not case sensitive.
True
False
False
189When determining whether a number is inside a range, it’s best to use this operator.
“&&
||
!
? :
“&&
190____ operators are used to determine whether a specific relationship exists between two values.
Arithmetic
Assignment
Relational
Logical
Relational
191If the expression on the left side of the && operator is false, the expression on the right side will not be checked.
True
False
True
192The if-else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false.
False
True
True
193This type of expression has a value of either true or false.
binary expression
unconditional expression
decision expression
boolean expression
boolean expression
194Programs never need more than one path of execution.
True
False
False
195Unicode is an international encoding system that is extensive enough to represent all the characters of all the world’s alphabets.
True
False
True
196Which of the following expressions will determine whether x is less than or equal to y?
x =< y
x => y
x >= y
x <= y
x <= y
197What will be the value of x after the following statements are executed?
5
30
25
20

20
198All it takes for an OR expression to be true is for one of the subexpressions to be true.
True
False
True
199The = operator and the == operator perform the same operation.
True
False
False
200The if statement is an example of a _____.
decision structure
pathway structure
sequence structure
class structure
decision structure
201Assume x is a double variable, and rand references a Random object. What does the following statement do?
x is set to the minimum possible double value.
x is set to the maximum possible double value.
x is going to be assigned to a random double value from 0.0 to 1.0.
x is set to a fixed value of 0.5.
x is going to be assigned to a random double value from 0.0 to 1.0.
202A loop that executes as long as a particular condition exists is called a(n) ____ loop.
count-controlled
conditional
relational
infinite
conditional
203This expression is executed by the for loop only once, regardless of the number of iterations.
test expression
pre-increment expression
update expression
initialization expression
initialization expression
204What classes do you use to read data from a file?
File and Scanner
DataInputStream and DataOutputStream
FileWriter and FileReader
PrintWriter and BufferedReader
File and Scanner
205This is a variable that controls the number of iterations performed by a loop.
repetition meter
accumulator
iteration register variable
loop control variable
loop control variable
206This is a special value that signals when there are no more items from a list of items to be processed) This value cannot be mistaken as an item from the list.
sentinel
flag
accumulator
signal
sentinel
207Before entering a loop to compute a running total, the program should first
read all the values into main memory
set all variables to zero
set the accumulator variable to an initial value, often zero
know exactly how many values there are to total
set the accumulator variable to an initial value, often zero
208A loop that repeats a specific number of times is known as a(n) ____ loop.
count-controlled
pretest
infinite
conditional
count-controlled
209When a program is finished using a file, it should do this.
reset the read position
close the file
throw an exception
erase the file
close the file
210The do-while loop is this type of loop.
pretest
prefix
posttest
postfix
posttest
211What clause must you write in the header of a method that performs a file operation?
catch FileNotFoundException
throws IOException
throws FileNotFoundException
try-catch IOException
throws IOException
212What is each repetition of a loop known as?
cycle
orbit
iteration
revolution
iteration
213The while loop is this type of loop.
pretest
postfix
prefix
posttest
pretest
214The variable that controls the number of times a loop iterates is known as a(n) ____.
loop control variable
running total
counter variable
decrement variable
loop control variable
215This class allows you to read a line from a file.
Scanner
FileWriter
InputFile
FileReader
Scanner
216An item that separates other items is known as a
sentinel
partition
terminator
delimiter
delimiter
217To open a file for reading, you use the following classes.
File and Scanner
File and Input
File and Writer
File and Output
File and Scanner
218A ____ loop will always be executed at least once.
conditional
posttest
pretest
user-controlled
posttest
219To open a file for writing, you use the following class.
FileReader
OutputFile
FileOpen
PrintWriter
PrintWriter
220A(n) ____ is a special value that cannot be mistaken as a member of a list of data items and signals that there are no more data items to be processed.
terminator
delimiter
sentinel
accumulator
sentinel
221The for loop is this type of loop.
pretest
prefix
posttest
postfix
pretest
222This class allows you to use the print and println methods to write data to a file.
PrintWriter
FileReader
File
OutputFile
PrintWriter
223In all but very rare cases, loops must contain, within themselves
a way to terminate
nested decision strucures
nested loops
arithmetic operators
a way to terminate
224The variable used to keep a running total in a loop is called a(n) ____.
accumulator
sentinel
integer
summation
accumulator
225What is the difference between an input file and an output file?
An output file is a file that data is written to. An input file is a file that data is read from.
An input file is used for writing data, while an output file is used for reading data.
They are the same.
Input and output files are used interchangeably.
An output file is a file that data is written to. An input file is a file that data is read from.
226This type of loop has no way of ending and repeats until the program is interrupted.
interminable
timeless
infinite
indeterminate
infinite
227Which of the following are pre-test loops?
while, for, do-while
while, do-while
for, do-while
while, for
while, for
228This is a variable that keeps a running total.
sentinel
total
accumulator
sum
accumulator
229This type of loop always executes at least once.
any of these
for
do-while
while
do-while
230A ____ is a value that signals when the end of a list of values has been reached.
token
terminal
delimiter
sentinel
sentinel
231The ____ loop allows the user to decide on the number of iterations.
counter controlled loop
dynamically executed loop
infinite loop
user controlled loop
user controlled loop
232If a loop does not contain, within itself, a valid way to terminate, it is called a(n) ____ loop
infinite
while
for
do-while
infinite
233The ____ loop is ideal in situations where the exact number of iterations is known.
do-while
posttest
for
while
for
234Each repetition of a loop is known as a(n) ____.
lap
cycle
iteration
execution
iteration
235Which is a control structure that causes a statement or group of statements to repeat?
prefix mode
block
body
loop
loop
236What class do you use to write data to a file?
FileWriterClass
FileReader
PrintWriter
FileWriter
PrintWrite
237What import statement will you need in a program that performs file operations?
import java.util.;
import java.math.;
import java.net.;
import java.io.;
import java.io.;
238The ____ loop is ideal in situations where you always want the loop to iterate at least once.
posttest
do-while
for
while
do-while
239What is the difference between an input file and an output file?
An output file is a file that data is written to. An input file is a file that data is read from.
They are the same.
Input and output files are used interchangeably.
An input file is used for writing data, while an output file is used for reading data.
An output file is a file that data is written to. An input file is a file that data is read from.