Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 27 discussion

Actual exam question from Salesforce's CRT-450
Question #: 27
Topic #: 1
[All CRT-450 Questions]

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()) {ג€¦}
Show Suggested Answer Hide Answer
Suggested Answer: ABC 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Mitu99
Highly Voted 2 years, 10 months ago
Selected Answer: ABC
abc is correct
upvoted 6 times
...
JuanVentura
Highly Voted 3 years, 5 months ago
Map<Id, Account> accountMap = new Map<Id, Account>([Select id, Name from Account]); for(Id accountId: accountMap.keySet()){ System.debug('accountId->A'+ accountId); } for(Account accountRecord: accountMap.values()){ System.debug('accountRecord->B'+ accountRecord); } for(Integer i= 0; i<accountMap.size(); i++){ System.debug('i ->C'+ i); } for(Id accountId: accountMap){ System.debug('accountId->D'+ accountId); } for(Account accountRecord: accountMap.keySet()){ System.debug('accountRecord->E'+ accountRecord); }
upvoted 5 times
...
ABHI0O07
Most Recent 8 months ago
explain how c is correct with code
upvoted 1 times
...
Nikospa11
10 months ago
Selected Answer: ABC
abc correct
upvoted 1 times
...
mwwt2022
1 year, 1 month ago
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()) {…}
upvoted 2 times
...
JuanVentura
3 years, 5 months ago
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)
upvoted 1 times
...
Beenal
3 years, 5 months ago
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
upvoted 2 times
...
Loosi
3 years, 7 months ago
instead of B, it should be E.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...