| Home | Links |

 Quiz on Loops

1. Every loop must run once.



2. If you don't move towards the stopping condition, the loop never ends.


3. The Boolean expression in a loop is the same as the stopping condition.



4. If the Boolean expression is true, then the loop keeps running.



5. All variables that are used after the loop must be declared outside the loop.



6. In Java, there are three types of loop constructs: while, for while, do while.



7. A loop is a code that repeats.



8. Which of the choices is NOT a part of the four elements of a loop?





9. What will the following code print on the screen?

for (double x = 15; x < 16; x ++)
{

System.out.print (x + " ");

}





10. What is wrong with the following code?

for (int x = 0; x <= 20; x +=3);
{

System.out.print (x + " ");

}





11. Which one of the statments is true for the code below?

int x = 5;
do
{

System.out.print (x + " ");
x += 5;

}
while (x <= 50);
System.out.println ("Done");





12. What kind of loop is this?

int x = 5;
while (x <= 10)
{

System.out.print (x + " ");
x ++;

}