Which type of loop is best known for using an index or counter?



Which type of loop is best known for using an index or counter?

A. do-while loop

B. for (traditional)

C. for-each

D. while

Answer:

B. for (traditional)

Explanation:

A traditional for loop is best known for having a loop variable counting up or down as the loop progresses. Therefore, Option B is correct. 

Options A and D are incorrect because do-while and while loops are known for their boolean conditions. 

Option C is incorrect because the for-each loop iterates through without an index.

Free Spring Boot Tutorial - 5 Hours Full Course


Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course

Comments