Multiple
Choice
Identify the letter of the choice that best completes the statement or answers the
question.
|
|
|
1.
|
During program development,
software requirements specify a. | how the program will accomplish the
task | d. | how to test the program when it is done | b. | what the task is that the program must perform | e. | all of the above | c. | how to divide the task into subtasks | | | | |
|
|
|
2.
|
In which phase of program
development would you expect the programmer(s) to determine the classes and objects
needed? a. | Software requirements | d. | Software testing | b. | Software design | e. | Could occur in any of the above | c. | Software implementation | | | | |
|
|
|
3.
|
Which of the following would
not be considered an algorithm? a. | a recipe | d. | a shopping list | b. | a computer program | e. | travel directions | c. | pseudocode | | | | |
|
|
|
4.
|
The idea that program
instructions execute in order (linearly) unless otherwise specified through a conditional statement
is known as a. | boolean execution | d. | sequentiality | b. | conditional statements | e. | flow of control | c. | try and catch | | | | |
|
|
|
5.
|
Of the following if statements,
which one correctly executes three instructions if the condition is true? a. | if (x < 0)
a = b *
2;
y =
x;
z = a
y; | c. | if { (x < 0)
a = b * 2;
y = x;
z = a y ;
}
| b. | {
if (x < 0)
a = b * 2;
y = x;
z = a y;
}
| d. | if (x < 0)
{
a = b * 2;
y = x;
z = a
y;
} | | | | |
|
|
|
6.
|
if
(a > 0)
if (b < 0)
x = x + 5;
else
if (a >
5)
x = x + 4;
else
x = x + 3;
else
x = x + 2;
If x is currently 0, a = 5 and b = 5, what will x become after the
above statement is executed?
|
|
|
7.
|
Consider the following code that will assign a letter grade of
A, B, C, D, or F depending on a
students test score.
if(score >= 90) grade = 'A';
if(score >= 80) grade = 'B';
if(score >= 70) grade = 'C';
if(score >= 60) grade = 'D';
else grade =
F; a. | This code will work correctly in all
cases | c. | This code will work correctly only if grade < 60 | b. | This code will work correctly only if grade >= 60 | d. | This code will work correctly only if
grade < 70 | | | | |
|
|
|
8.
|
If x is an int where x = 1, what will x be after the following loop
terminates?
while (x <
100)
x *= 2; a. | 2 | d. | 128 | b. | 64 | e. | this is an infinite loop
| c. | 100 | | | | |
|
|
|
9.
|
If x is an int where x = 0, what will x be after the following loop
terminates?
while (x < 100)
x *= 2;
a. | 2 | d. | 128 | b. | 64 | e. | this is an infinite
loop | c. | 100 | | | | |
|
|
|
Use the following class definition to answer questions 1-4.
public class
Questions1_4
{
public static void main(String[ ]
args)
{
System.out.print("Here");
System.out.println("There " +
"Everywhere");
System.out.println("But not" +
"in Texas");
}
}
|
|
|
10.
|
The program will
print the word "Here" and then print a. | "There
Everywhere" on the line after "Here" | d. | "ThereEverywhere" on
the same line as "Here" | b. | "There" on the line
after "Here" and "Everywhere" on the line after
"There" | e. | "ThereEverywhere" on the line after
"Here" | c. | "There
Everywhere" on the same line as "Here" | | | | |
|
|
|
11.
|
The final println
command will output a. | "But not
in Texas" | d. | "But not+in Texas" | b. | "But notin
Texas" | e. | "But not + in
Texas" | c. | "But not" on one
line and "in Texas" on the next line | | | | |
|
|
|
12.
|
How many lines of
output are provided by this program?
|
|
|
13.
|
A reasonable comment
for this program might be a. | // a program that
demonstrates the differences between print, println and how + works | d. | // a program that outputs the
message Here There Everywhere But not in Texas | b. | // a program that outputs a message about
Texas | e. | // a program that has three output statements in
it | c. | // a program that demonstrates
nothing at all | | | | |
|
|
|
14.
|
If you want to output
the text "hi there", including the quote marks, which of the following could do
that? a. | System.out.println("hi
there"); | d. | System.out.println("\"hi
there\""); | b. | System.out.println(""hi there""); | e. | System.out.println("\"hi there\""); | c. | System.out.println("\"hi
there"); | | | | |
|
|
|
15.
|
Of the following
types, which one cannot store a numeric value? a. | int | d. | all of these can store numeric
values | b. | double | e. | none of these can store numeric
values | c. | char | | | | |
|
|
|
16.
|
What value will z
have if we execute the following assignment statement? a. | z will equal 0.0 | d. | z will equal
0.05 | b. | z will equal
0.5 | e. | z will equal 0.05 | c. | z will equal 5.0 | | | | |
|
|
|
17.
|
A cast is required in
which of the following situations? a. | using charAt to take an element
of a String and store it in a char | d. | storing a double in an
int | b. | storing an int in a
double | e. | all of the above require casts | c. | storing a double in a double | | | | |
|
|
|
18.
|
What will be the result of the following assignment statement?
Assume b = 5 and c = 10.
int a = b * (-c + 2) / 2;
|
|
|
19.
|
What is output with
the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? a. | 15 | d. | x+y | b. | 105 | e. | An error since neither x nor y
is a String | c. | 10.5 | | | | |
|