This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
A developer writes an application that uses a foreach loop to iterate through an array containing 20 elements. After the application is complete, the developer learns that the array must be updated to include 40 elements. The application needs to examine all 40 array elements. Which of the following items describes the required code update?
foreach
Create a second foreach loop that iterates through the additional items.
No changes are required to the foreach loop.
Place the original foreach loop inside the code block of a second foreach loop that iterates twice.
A developer is working on a nested foreach structure that iterates through all of an application's data arrays. The first array contains the names of locations where water samples were collected. The remaining arrays contain the test results for the samples collected from each named location. Which of the following statements about how the arrays should be processed is correct?
Each of the arrays containing samples can be processed by the outer loop, the inner loop will be used to verify the location.
The order in which the arrays are processed doesn't matter since the application has to process all of the data.
The outer loop must process the array containing locations, the inner loop must process the arrays containing samples.
You must answer all questions before checking your work.
Was this page helpful?