AP Computer Science Aeasymcq1 pt

Which loop correctly visits every element of array a?

A.for (int i = 0; i < a.length; i++)
B.for (int i = 0; i ≤ a.length; i++)
C.for (int i = 1; i < a.length; i++)
D.for (int i = a.length; i > 0; i--)

Explanation

Core Concept

The loop covers indexes 0 to length minus one.

Correct Answer

Afor (int i = 0; i < a.length; i++)

More Unit 6: Array practice questions

Try a random question →

Practice more AP Computer Science A questions with full explanations

Practice Unit 6: Array Questions →