for loops

Instructions: For each question, choose the single best answer.
When the practice is graded, the correct answers will appear in the box after each question.



1. Consider this for line:    for(int k = 1; k <= 6; k = k+1)
Which part determines when the loop will stop

A.    k <= 6
B.   int k = 1
C.    k = k+1
D.    the word for

2. Consider this for loop:     for(int k = 1; k <= 20; k = k+3)
What will be the values of "k"?

A.    1 2 3 4 5 6 7 8 ... 20
B.    1 4 7 10 13 16 19
C.    1 3 5 7 ... 19
D.    0 3 6 9 12 15 18

3. Which is another way to write     k +=4

A.    k = 4
B.    k = + 4
C.    k++++
D.    k = k + 4

4. Which is another way to write    k--

A.    k = k - 1
B.    k =-1
C.    k - 1
D.    there is no other way

5. Consider this for loop         for(int k = 1; k <=7; k++)
What will be the values of   "k"

A.    1 3 5 7
B.    1 2 3 4 5 6 7
C.    0 1 2 3 4 5 6
D.    1  8

6. Consider this for loop:  for(int k = 10; k <=1 ; k-= 2)
What will be the values of "k"?

A.    nothing
B.    10 9 8 7 ... 1
C.    10 8 6 4 2
D.    endless loop
E.    10 8 6 4 2 1

7. Consider this for loop:    for(int j = 5; j >=1 ; j++)
What will the values of "j" ?

A.    1 2 3 4 5
B.    you can not use "j" for a loop
C.    5 6 7 8 9 ... endless loop
D.    5 4 3 2 1

8. Consider this for loop:    for(int k =0; k<=100 ; k += 5)
                                                g.fillOval(k, 10, 5, 5);
What will print?

A.    horizontal row of ovals
B.    vertical row of ovals
C.    diagonal row of ovals
D.    one long oval

9. Consider this for loop:    for(int k =0; k<=100 ; k += 5)
                                                g.fillOval(10, k, 5, 5);
what will print?

A.   diagonal row of ovals
B.   horizontal row of ovals
C.    vertical row of ovals
D.    not possible to tell

10. Consider this for loop:    for(int k =0; k<=100 ; k += 5)
                                                g.fillOval(k, k, 5, 5);
Which describes what will print?

A.    the size of the ovals will change
B.    horizontal row of ovals
C.    vertical row of ovals
D.    the horizontal and vertical location will change

The number you got right:       Percent Correct:       Letter Grade: