Worksheets29W Quiz 1 - PLTW
Total questions: 15
Worksheet time: 8mins
What will be the value of count as a result of executing the code segment?
100
161
241
341
What value is stored in the variable count as a result of executing the code segment?
16
11
71
1
Which of the following can be used to replace
/* missing condition */ so that the method will work as intended?
count != 0
num != 0
num == 0
count !=-= 0
Which of the following can be used as a replacement for /* missing loop header */ so that the code segment prints out the string "1 2 3 4 "?
while (k < 3)
while (k < 4)
while (k < 5)
while (k <= 4)
What is printed as a result of executing the code segment?
A-
AAA
A
AA
Code segment 1 prints the sum of the integers from 1 through 30, inclusive. Which of the following best explains how the output changes from code segment 1 to code segment 2 ?
Code segment 2 will print the sum of only the odd integers from 1 through 30, inclusive because it starts k at one, increments k by twos, and terminates when k exceeds 30.
Code segment 1 will print the sum of only the odd integers from 1 through 50, inclusive because it starts k at one, increments k by twos, and terminates when k exceeds 30.
Code segment 1 and 3 will print the sum of only the odd integers from 1 through 75, inclusive because it starts k at one, increments k by twos, and terminates when k exceeds 30.
Code segment 2 will print the sum of only the odd integers from -5 through -30, inclusive because it starts k at one, increments k by twos, and terminates when k exceeds 30.
Which of the following best explains how the output changes from code segment I to code segment II?
The code segments print the same values but in a different order, because code segment III iterates from 11 to 15 and code segment II iterates from 15 to 21.
The code segments print the same values but in a different order, because code segment II iterates from 1 to 5 and code segment II iterates from -5 to -1.
The code segments print the same values but in a different order, because code segment I iterates from 2 to 6 and code segment II iterates from 5 to 1.
The code segments print the same values but in a different order, because code segment I iterates from 1 to 5 and code segment II iterates from 5 to 1.
Which of the following code segments will produce the same output as the code segment above?
for (int k = 0; k <= 18; k += 2)
for (int k = 0; k <= 8; k += -2)
What, if anything, is printed when the code segment is executed?
B
A & B
C
C & D
What is printed as a result of executing the code segment?
true
true =
true
false
false
true
true
false
true
false =
false
true =
What is printed as a result of executing this code segment?
6
5
4
3
What is printed as a result of executing the code segment?
eeSepC
e C
ci tm
n c e P
What value is returned as a result of the method call changeStr("12345") ?
"13"
23"
"183"
"53"
Which of the following best explains the effect, if any, of changing the first line of code to int j = 0; ?
There will be one less value printed because the outer loop will iterate one fewer time.
There will be six more values printed because the outer loop will iterate one or more additional times.
There will be four more values printed because the outer loop will iterate one additional time.
There will be no more values printed because the outer loop will iterate zero additional times.
Which of the following best explains how changing the outer for loop header to for (int j = 0; j <= 3; j++) affects the output of the code segment?
The string "Fun" will be printed more times because the outer loop will execute more times.
The string "EHS" will be printed more times because the outer loop will execute more times.
The string "String" will be printed more times because the outer loop will execute more times.
The string "SISD" will be printed more times because the outer loop will execute more times.
