Question: The multiple choice answers have been provided for each question. Thanks in advance. 1.) Given the following for loop, how many numbers will be printed?
The multiple choice answers have been provided for each question. Thanks in advance.
1.)
Given the following for loop, how many numbers will be printed?
for(int a = 0; a<10; a++)
System.out.println(a);
8
9
10
11
2.)
Given the following while loop, what is the final value of y?
int x = 0;
int y=0;
do
{
y=x;
x++;
} while (x <= 10);
8
9
10
11
3.)
What will cause the following code to generate an error?
public static void main (String[] args)
{
int numValue=5;
for (i = 0; i < numValue; ++i) {
int newValue;
newValue = numValue * i;
}
System.out.println("Last value: " + newValue);
}
numValue is out of scope in the for-loop.
newValue is out of scope in the main method.
newValue and i are out of scope.
The loop expression will never evaluate to false.
4.)
Which decision control structure is used as a test after the loop already executes?
Group of answer choices
do-while loop
while loop
for loop
nested loop
5.)
Given the following for loop, how many numbers will be printed? for(int a = 0; a<10; a++)
System.out.println(a);
Group of answer choices
8
9
10
11
6.)
Which of the following loops will execute even if the initial loop-condition is false?
Group of answer choices
do-while loop
while loop
for loop
nested loop
7.)
Given the following while loop, what is the final value of y?
int x = 0;
int y=0;
while (x <= 10)
{
y=x*2;
x++;
}
Group of answer choices
10
11
12
20
8.)
What type of value can be used to denote the end of input for a loop or Java operation?
Group of answer choices
Sentinel value
Loop value
Initialization value
Conditional value
9.)
Forgetting to update a variable in the body, or creating a loop expression whose evaluation to false is not always reachable, can cause a(n) ________.
Group of answer choices
ultimate loop
max loop
for-while loop
Infinite loop
10.)
What is the minimum number of times that a while-loop will execute?
Group of answer choices
0
1
2
3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
