IfIsLoop
Misconception:
The body of the if
-statement executes as many times as needed
to ensure the condition does not hold anymore and execution can continue.
Incorrect
The body of an if statement executes repeatedly, as long as the condition holds
Correct
The body of an if statement executes at most once
CorrectionHere is what's right.
Here is what's right.
The body of an if
-statement either executes,
or it does not execute.
Students might mistake if
-statements for while
-statements.
Conditional: Execute body zero or one times
if (a > 0) {
a = a - 1;
}
Loop: Execute body zero or more times
while (a > 0) {
a = a - 1
}
SymptomsHow do you know your students might have this misconception?
How do you know your students might have this misconception?
- Students claim an
if
-statement means “ensure that this condition holds” - Students claim an
if
-statement “corrects things whenever this condition does not hold”
Language
Java