Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What will be the output of the following code? 'for (int i = 1; i <= 3; i++) { System.out.println(i); }'
Look at how many times the loop runs.
In a 'while' loop, where is the condition checked?
Think about when the loop starts and stops.
What type of loop would you use when you know the number of iterations?
Remember the structure of the for loop.
A 'do-while' loop runs at least how many times?
Consider the order of execution in this loop type.
Using a for loop, write a program that calculates the sum of integers from 1 to 100.
Consider how you can keep adding numbers to a total.
Create a program with a while loop that repeatedly prompts a user to enter their age until they enter a non-negative number.
Use a condition that allows exit from the loop for valid input.
5 more questions in this section. Enroll free to practise them all.
Enroll free