Practice Challenges for Fun
This lesson contains tasks to let you practice what we learned in this chapter.
We'll cover the following...
Quiz
Attempt the following quiz questions:
1.
The logic of a for statement is the same as the logic of a while statement. The bodies of the loops controlled by these statements might not execute at all. When should you use a for statement instead of a while statement? When should you use a while statement instead of a for statement?
0/500
Show Answer
1 / 4
1
What output would the following code display?
for (double sample = 2; sample > 0; sample = sample - 0.5 )
System.out.println(sample);
A)
2.0 1.5 1.0 0.5
B)
2.0 1.5 1.0
C)
1.5 1.0 0.5
Question 1 of 20 attempted
Challenge 1: Two loops to
... Ask