Which type of loop is best known for its boolean condition that controls entry to the loop?

Which type of loop is best known for its boolean condition that controls entry to the loop?

A. do-while loop

B. for (traditional)

C. for-each

D. while

Answer:

D. while

Explanation:

A while loop has a condition that returns a boolean that controls the loop. It appears at the beginning and is checked before entering the loop. Therefore, Option D is correct. 

A traditional for loop also has a boolean condition that is checked before entering the loop. However, it is best known for having a counter variable, making Option B incorrect. 

Option A is incorrect because the boolean condition on a do-while loop is at the end of the loop. Option C is incorrect because there is no condition as part of the loop construct.

Comments