Salesforce Platform Developer I (legacy) — Question 24

Given:
Map<ID, Account> accountMap = new Map>ID, Account> ([SELECT Id, Name FROM Account]);
What are three valid Apex loop structures for iterating through items in the collection? (Choose three.)

Answer options

Correct answer: A, B, C

Explanation

The correct answers A and B utilize valid methods for iterating over keys and values in the map. Option C is also valid as it allows iteration based on the size of the map. Options D and E are incorrect because D attempts to iterate directly over a map, which is not valid, and E incorrectly tries to use keySet for values.