The Basic For-Loop
The for-loop on this page is an example of a
very common idiom in Java. The questions for this loop
review the fundamental terms, concepts and qualities of
for-loops. These questions can be asked
about any for-loop, and many will be asked
about more complicated loops elsewhere on this site.
Download files: TheBasicForLoop.java
Areas: Introduction to loops.
Download files: TheBasicForLoop.java
Areas: Introduction to loops.
|
|
TheBasicForLoop.java |
|
|
| Question 1 |
| What is the body of the loop? |
| Question 2 |
| What is the test of the loop? |
| Question 3 |
| What is the loop counter? |
| Question 4 |
| What is the step-size of the loop? |
| Question 5 |
| What is the starting value of the loop counter? |
| Question 6 |
| What is the value of the loop counter the last time the loop is executed? |
| Question 7 |
| What does the body of the loop do? |
| Question 8 |
| What does the loop do? |
| Question 9 |
| What is the value of i after the loop exits? |
| Question 10 |
| What is the value of the loop counter the last time it is tested? |
| Question 11 |
| Where in the code is the loop counter incremented? |
| Question 12 |
| When during execution is the loop counter incremented? |
| Question 13 |
| Where in the code is the loop counter tested? |
| Question 14 |
| When during execution is the loop counter tested? |
| Question 15 |
| How many times will the body of the loop be executed? |
| Question 16 |
| How many times will the test be evaluated? |
| Question 17 |
| How many times will the loop counter be incremented? |
| Question 18 |
| Where is the loop counter declared? |
| Question 19 |
| Where in the code is the loop counter initialized? |
| Question 20 |
| How many ways are there for the loop to exit? |
| Question 21 |
| Which parts of this code can cause the loop to exit? |
| Question 22 |
| Under what conditions will this loop exit? |
