Salesforce Platform Developer I (legacy) — Question 213

What are two valid options for iterating through each Account in the collection List<Account> named AccountList? (Choose two.)

Answer options

Correct answer: A, D

Explanation

Option A is correct because it uses the enhanced for loop to directly access each Account in AccountList. Option D is also valid as it employs a traditional for loop to iterate through the List using an index. Options B and C are incorrect since they do not properly reference the elements in the collection; B lacks the correct loop syntax and C incorrectly tries to iterate over a List type instead of the Account type.