function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vinu VargheseVinu Varghese 

Apex loop

Given Map<Id, Account> accountMap = new Map<Id, Account> {[SELECT Id, Name FROM Account]}; What are three valid Apex loop structures for iterating items in the collection?
Choose 3 answers
a.       For(ID accountId : accountMap.keySet()) {--}
b.      For(Account accountRecord : accountMap.value()) {--}
c.       For( Integer i=0; i< accountMap.size(); i++) {--}
d.      For(ID accountId : accountMap) {--}
e.      For(Account accountRecord : accountMap.keySet()) {--}

I think A,B,C
Vishwajeet kumarVishwajeet kumar
Hello,
Not sure if records from query data is required in other places(in Class), if it is not it can be combined as below.

For(Account v_Account : [SELECT Id, Name FROM Account]){
      System.debug('Account Name::' + v_Account.Name);
}

Thanks.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Vinu,

I see that this is a question that might be related to a certification exam and Please be advised that this community is focused on Salesforce technical discussions where the forums and participants are geared toward programming troubleshooting and support. 

You can easily check the behaviour of which would work by simply taking and simply executing the scenario.

I hope you understand and going forward I would request you to not post such questions in the forum.

Regards,
Salesforce Support.