stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
For Loops Flashcards | StudBud
Explore
/
For Loops
For Loops
12 terms
·
StudBud Administration
·
138 plays
#forloops in #java for an introductory course in #computerscience
Flashcards
12 cards
F
Practice quiz
P
Host live
L
Questions
12
Answers
1
What is the term for a loop inside another loop?
matryoshka loops
concave loops
embedded loops
nested loops
2
If an outer for loop iterates 6 times and an inner for loop iterates 7 times, how many times will the inner loop run?
42
67
76
13
3
In the following for loop, which could replace 'C'?
for(
A
;
B
;
C
)
D;
int i = 0;
i++;
System.out.println("Run "+i);
i <= 5;
4
How many times will this for loop execute
for (int i = 0; i <=5; i++) /* LOOP CODE */
5
1
6
0
5
How many times will this for loop execute
for (int i = 0; i <=12; i+=3) /* LOOP CODE */
5
3
12
4
6
In the following for loop, which could replace 'A'?
for(
A
;
B
;
C
)
D;
System.out.println("Run "+i);
i <= 5;
int i = 0;
i++;
7
In the following for loop, which would best replace 'D'?
for(
A
;
B
;
C
)
D;
int i = 0;
i <= 5;
System.out.println("Run "+i);
i++;
8
In the following for loop, which could replace 'B'?
for(
A
;
B
;
C
)
D;
int i = 0;
i <= 5;
System.out.println("Run "+i);
i++;
9
Consider the loop:
for (int i = 1; i<10;i++) /*CODE*/
which code would produce an infinite loop?
i = 10;
break;
i+=2;
i--:
10
How many times will this for loop execute
for (int i = 64; i >1; i/=2) /* LOOP CODE */
8
64
6
4
11
In general,
loops
in code are a way to...
repeatedly run a code block until a specific condition is met
perform math calculations
call a method multiple times
repeat endlessly
12
What coding task would be most straightforwardly accomplished using a for loop?
Prompting a user for exactly 5 test grades
performing 5 different mathematical operations on a variable
choosing a random number between 1 and 5
calculating the mean of 5 integers