Java OCA OCP Practice Question 880

Question

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


D.

Note

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.

Option D is correct.

A traditional for loop also has a boolean condition that is checked before entering the loop.

It is 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.




PreviousNext

Related