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.)
A.
for (ID accountID : accountMap.keySet()) {ג€¦}
B.
for (Account accountRecord : accountMap.values()) {ג€¦}
C.
for (Integer i=0; I < accountMap.size(); i++) {ג€¦}
D.
for (ID accountID : accountMap) {ג€¦}
E.
for (Account accountRecord : accountMap.keySet()) {ג€¦}
choices:
A. for (ID accountID : accountMap.keySet()) {…}
B. for (Account accountRecord : accountMap.values()) {…}
C. for (Integer i=0; I < accountMap.size(); i++) {…}
D. for (ID accountID : accountMap) {…}
E. for (Account accountRecord : accountMap.keySet()) {…}
I see what happend here, the person who creates this question, just cheked those staments, and only work for ABC, so in that context DE are worng,
But you are asumming that some code is missing on those (DE)
E cannot be the right answer as Keyset contains Id so in order to loop it needs ID
For(ID thisloop: Map.keyset()) is correct
For(Account acc: Map.keyset()) is incorrect
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Mitu99
Highly Voted 2 years, 10 months agoJuanVentura
Highly Voted 3 years, 5 months agoABHI0O07
Most Recent 8 months agoNikospa11
10 months agomwwt2022
1 year, 1 month agoJuanVentura
3 years, 5 months agoBeenal
3 years, 5 months agoLoosi
3 years, 7 months ago