Quiz Bank Mid Term

239 flashcardsby Oliver_S
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
Logical errors are mistakes that cause the program to produce erroneous results.

True or False
True
2
The original name for Java was

Elm
HotJava
Oak
JavaScript
Oak
3
What 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
4
There are __________ bits in a byte.

4
8
16
32
8
5
Without programmers, the users of computers would have no software, and, without software, computers would not be able to do anything.

True or False
True
6
These are words that have a special meaning in the programming language.

punctuation
key words
operators
programmer-defined names
key words
7
The computer is a tool used by so many professionals that it cannot be easily categorized.

True or False
True
8
The end of a Java statement is indicated by a ________.

bracket (})
asterisk (*)
semicolon (;)
colon (:)
semicolon (;)
9
Computer programming is
an art
a science
neither of the above
both of the above
both of the above
10
A procedure is a set of programming language statements that, together, perform a specific task.
True
False
True
11
The Java compiler generates
machine code
source code
byte code
HTML
byte code
12
These are the rules that must be followed when writing a program
key words
syntax
punctuation
operators
syntax
13
JVM stands for
Java Virtual Method
Java Variable Method
Java Variable Machine
Java Virtual Machine
Java Variable Machine
14
Validating 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
15
A cross between human language and a programming language is called
the Java language
the Java Virtual Machine
a compiler
pseudocode
pseudocode
16
The Java Virtual Machine is a program that reads Java byte code instructions and executes them as they are read.
True
False
True
17
Which of the following will run the compiled program called ReadIt?
java ReadIt
run ReadIt
go ReadIt
java ReadIt.java
java ReadIt
18
The 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)
19
Byte 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
20
Which of the following will compile a program called ReadIt?
java ReadIt.java
javac ReadIt.java
javac ReadIt.javac
java ReadIt.javac
javac ReadIt.java
21
Software refers to
firmware
programs
the physical components a computer is made of
data stored in RAM
programs
22
Each byte is assigned a unique number known as an address
True
False
True
23
A solid-state drive has no moving parts and operates faster than a traditional disk drive.
True
False
True
24
Application 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
25
Because 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
26
Key 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
27
Each different type of CPU has its own
syntax
firmware
machine language
software
machine language
28
Internally, 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)
29
Byte 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
30
These are symbols or words that perform operations on one or more operands.
programmer-defined names
operators
punctuation
key words
operators
31
Encapsulation refers to the combining of data and code into a single object.
True
False
True
32
These 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
33
Each byte is assigned a unique
Bit
address
CPU
Variable
address
34
Java was developed by
Sun Microsystems
IBM
Microsoft
Hewlett-Packard
Sun Microsystems
35
A 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
36
Colons are used to indicate the end of a Java statement.
True
False
False
37
Java source files end with the .class extension.
True
False
False
38
A runtime error is usually the result of
a logical error
a syntax error
a compiler error
bad data
a logical error
39
Java source files end with the .class extension.
True
False
False
40
RAM 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
41
One 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
43
A byte is made up of eight
variables
CPUs
bits
addresses
bits
44
When 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
45
A(n) __________ is a software entity that contains data and procedures.
object
method
class
program
object
46
Computers can do many different jobs because they are
automated
reliable
programmable
electronic
programmable
47
A 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
48
Application software refers to programs that make the computer useful to the user
True
False
True
49
Compiled byte code is also called source code.
True
False
False
50
Which 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
52
Which 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
53
These 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
54
While __________ 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
55
A(n) __________ is used to write computer programs.
application
programming language
operating system
pseudocode document
programming language
56
If 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
57
This 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
58
Variables 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
59
This is a named storage location in the computer’s memory
operator
key word
class
variable
variable
60
The contents of a variable cannot be changed while the program is running.
True
False
False
61
Which 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
62
A set of programming language statements that perform a specific task is a(n)
object
source code
procedure
pseudocode chart
procedure
63
The 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
64
An 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
65
A program is a sequence of instructions stored in
software
firmware
the computer's memory
the CPU
the computer's memory
66
This 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
67
Which 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";
68
Java is not case sensitive.
False
True
False
69
Which 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);
70
The System.out.printf method allows you to format output in a variety of ways.
True
False
True
71
Which of the following are not valid assignment statements? (Indicate all that apply.)
letter = 'W';
total = 9;
profit = 129
72 = amount;
profit = 129
72 = amount;
72
A variable must be declared before it can be used.
True
False
True
73
The primitive data types only allow a(n) ____ to hold a single value.
class
literal
object
variable
variable
74
Which of the following is not a primitive data type?
short
long
float
string
string
75
The 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
76
If 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
77
Which 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;
78
A Java source file must be saved with the extension
.java
.javac
.src
.class
.java
79
Which Scanner class method would you use to read a string as input?
nextLine
nextString
getLine
readString
nextLine
80
This 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
81
When 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
82
Which of the following cannot be used as identifiers in Java?
class names
variable names
key words
objects
key words
83
A variable’s scope is the part of the program that has access to that variable.
True
False
True
84
To 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
85
You cannot change the value of a variable whose declaration uses the final key word.
True
False
True
86
Which 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;
87
Which 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.
88
The Java API provides a class named Math that contains numerous methods which are useful for performing complex mathematical operations.
False
True
True
89
What 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.
90
To 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”);
91
Variable names may begin with a number.
True
False
False
92
Comments that begin with // can be processed by javadoc.
True
False
False
93
When 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
94
Which 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
95
What 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
96
Class names and key words are examples of variables.
False
True
False
97
You can use this class to display dialog boxes.
InputStreamReader
DialogBox
BufferedReader
JOptionPane
JOptionPane
98
This key word is used to declare a named constant.
final
namedConstant
concrete
constant
final
99
A left brace in a Java program is always followed by a right brace later in the program.
True
False
True
100
Character 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
101
Programming style includes techniques for consistently putting spaces and indentation in a program to help create visual cues.
False
True
True
102
Which of the following is a named storage location in the computer’s memory?
an operator
a variable
a literal
a constant
a variable
103
To 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
104
These characters mark the beginning of a documentation comment.
*

//
*/
*
105
Named constants are initialized with a value and that value cannot change during the execution of the program.
False
True
True
106
A 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 {}
107
The following data (72, 'A', "Hello World", 2.8712) are all examples of
literals
strings
none of these
variables
literals
108
What 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
109
A 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
110
If 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;
111
Variables are classified according to their
locations
values
data types
names
data types
112
Both character and string literals can be assigned to a char variable.
True
False
False
113
Which Scanner class method reads a String?
nextLine
getLine
charAt
nextString
nextLine
114
Every Java application program must have
at least two data types
a class named MAIN
integer variables
a method named main
a method named main
115
Every complete statement ends with a .

period
ending brace
parenthesis
semicolon
semicolon
116
The negation operator is .
none of these
ternary
binary
unary
unary
117
A value that is written into the code of a program is a(n) ____.
operator
literal
variable
assignment statement
literal
118
These characters mark the beginning of a multi-line comment.
//
*/
*
119
These characters mark the beginning of a single-line comment.

*
//
*/
//
120
Which of the following is not a valid Java comment?
Comment one /
/ Comment four /
// Comment three
/ Comment two /
/ Comment two /
121
In 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
122
When the + operator is used with strings, it is known as the
addition operator
string concatenation operator
combines assignment operator
assignment operator
string concatenation operator
123
Which 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
124
If the compiler encounters a statement that uses a variable before the variable is declared, an error will result.
True
False
True
125
What is the result of the following expression? 10 + 5 * 3 - 20
-5
25
-50
5
5
126
In Java, ____ must be declared before they can be used)
literals
variables
key words
comments
variables
127
What is the result of the following expression? 17 % 3 * 2 - 12 + 15
7
105
12
8
7
128
A Java program will not compile unless it contains the correct line numbers.
False
True
False
129
Which 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
130
What 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
131
Variables 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
132
All lines in a conditionally executed block should be indented one level.
False
True
True
133
Which 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)
134
The 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
135
This determines whether two different String objects contain the same string.
the = operator
the equals method
the stringCompare method
the == operator
the equals method
136
What would be the value of discountRate after the following statements are executed?



.03
.01
0
.05
.01
137
The ____ 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
138
Which 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))
139
An 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
140
Which 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);
141
What will be the value of discountRate after the following statements are executed?
0.08
0.06
0.0
0.04
0.0
142
The System.out.printf method formats a string and displays it in the console window.
True
False
True
143
How 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’
144
The conditional operator takes this many operands.
three
two
one
four
three
145
What 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
146
To create a block of statements, you enclose the statements in these.
angled brackets <>
square brackets []
parentheses()
braces {}
braces {}
147
What will be the value of pay after the following statements are executed?
400.00
475.00
450.00
465.00
475.00
148
This 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
150
In 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
151
A ____ is a boolean variable that signals when some condition exists in the program.
flag
sentinel
block
case
flag
152
What would be the value of bonus after the following statements are executed?
1500
1000
2000
1250
1000
153
If 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)
154
This 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
155
What will be displayed after the following statements are executed?

The code contains an error and will not compile.
10
120
100
120
156
In 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
157
What 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
159
The boolean expression in an if statement must evaluate to
positive or negative
left or right
true or false
degrees or radians
true or false
160
The scope of a variable is limited to the block in which it is defined.
False
True
True
161
What is the value of charges after the following code has been executed?
14.00
28.00
21.00
7.00
21.00
162
When 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
163
Java 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
164
A conditionally executed statement should be indented one level from the if clause.
False
True
True
165
This section of a switch statement is branched to if none of the case expressions match the switch expression.
otherwise
else
default
case
default
166
You 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
167
Which 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’
168
All it takes for an AND expression to be true is for one of the subexpressions to be true.
True
False
False
169
The switch statement is a
nested decision structure
test expression
sequence structure
multiple alternative decision structure
multiple alternative decision structure
170
What 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
172
What 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.
173
Which of the following is the not equal operator?
*&
NOT
!=
<>
!=
174
This is a boolean variable that signals when some condition exists in the program.
sentinel
flag
signal
siren
flag
175
A block of code is enclosed in a set of
brackets, [ ]
braces, { }
double quotes, ” “
parentheses, ( )
braces, { }
176
If 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)
177
What 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
179
Which 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)
180
An expression tested by an if statement must evaluate to
0 or 1
true or false
t or f
+1 or -1
true or false
181
In a switch statement, each of the case values must be unique.
True
False
True
182
In 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
183
Which 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);
184
When testing for character values, the switch statement does not test for the case of the character.
False
True
False
185
A flag may have the values
of any range of integers
defined or undefined
of any Unicode character
true or false
true or false
186
Which 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))
187
A local variable’s scope always ends at the closing brace of the block of code in which it is declared.
False
True
True
188
When two strings are compared using the String class’s compareTo method, the comparison is not case sensitive.
True
False
False
189
When 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
191
If the expression on the left side of the && operator is false, the expression on the right side will not be checked.
True
False
True
192
The 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
193
This type of expression has a value of either true or false.
binary expression
unconditional expression
decision expression
boolean expression
boolean expression
194
Programs never need more than one path of execution.
True
False
False
195
Unicode is an international encoding system that is extensive enough to represent all the characters of all the world’s alphabets.
True
False
True
196
Which 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
197
What will be the value of x after the following statements are executed?
5
30
25
20
20
198
All it takes for an OR expression to be true is for one of the subexpressions to be true.
True
False
True
199
The = operator and the == operator perform the same operation.
True
False
False
200
The if statement is an example of a _____.
decision structure
pathway structure
sequence structure
class structure
decision structure
201
Assume 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.
202
A loop that executes as long as a particular condition exists is called a(n) ____ loop.
count-controlled
conditional
relational
infinite
conditional
203
This 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
204
What 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
205
This 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
206
This 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
207
Before 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
208
A loop that repeats a specific number of times is known as a(n) ____ loop.
count-controlled
pretest
infinite
conditional
count-controlled
209
When 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
210
The do-while loop is this type of loop.
pretest
prefix
posttest
postfix
posttest
211
What 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
212
What is each repetition of a loop known as?
cycle
orbit
iteration
revolution
iteration
213
The while loop is this type of loop.
pretest
postfix
prefix
posttest
pretest
214
The 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
215
This class allows you to read a line from a file.
Scanner
FileWriter
InputFile
FileReader
Scanner
216
An item that separates other items is known as a
sentinel
partition
terminator
delimiter
delimiter
217
To 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
218
A ____ loop will always be executed at least once.
conditional
posttest
pretest
user-controlled
posttest
219
To open a file for writing, you use the following class.
FileReader
OutputFile
FileOpen
PrintWriter
PrintWriter
220
A(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
221
The for loop is this type of loop.
pretest
prefix
posttest
postfix
pretest
222
This class allows you to use the print and println methods to write data to a file.
PrintWriter
FileReader
File
OutputFile
PrintWriter
223
In 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
224
The variable used to keep a running total in a loop is called a(n) ____.
accumulator
sentinel
integer
summation
accumulator
225
What 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.
226
This type of loop has no way of ending and repeats until the program is interrupted.
interminable
timeless
infinite
indeterminate
infinite
227
Which of the following are pre-test loops?
while, for, do-while
while, do-while
for, do-while
while, for
while, for
228
This is a variable that keeps a running total.
sentinel
total
accumulator
sum
accumulator
229
This type of loop always executes at least once.
any of these
for
do-while
while
do-while
230
A ____ is a value that signals when the end of a list of values has been reached.
token
terminal
delimiter
sentinel
sentinel
231
The ____ 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
232
If a loop does not contain, within itself, a valid way to terminate, it is called a(n) ____ loop
infinite
while
for
do-while
infinite
233
The ____ loop is ideal in situations where the exact number of iterations is known.
do-while
posttest
for
while
for
234
Each repetition of a loop is known as a(n) ____.
lap
cycle
iteration
execution
iteration
235
Which is a control structure that causes a statement or group of statements to repeat?
prefix mode
block
body
loop
loop
236
What class do you use to write data to a file?
FileWriterClass
FileReader
PrintWriter
FileWriter
PrintWrite
237
What 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.;
238
The ____ loop is ideal in situations where you always want the loop to iterate at least once.
posttest
do-while
for
while
do-while
239
What 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.
Study all 239 cards for free