Salesforce
PDII · Question #409
Given a list of Opportunity records named opportunityList, which code snippet is best for querying all Contacts of the Opportunity's Account?
The correct answer is C. List <Contact> contactList = new List <Contact>(); Set <Id> accountIds = new Set <Id> (). See the full explanation below for the reasoning.
Question
Given a list of Opportunity records named opportunityList, which code snippet is best for querying all Contacts of the Opportunity's Account?
Options
- AList <Contact> contactList = new List <Contact>(); for(Opportunity o : opportunityList){ Account a =
- BList <Contact> contactList = new List <Contact>(); Set <Id> accountIds = new Set <Id> (); for
- CList <Contact> contactList = new List <Contact>(); Set <Id> accountIds = new Set <Id> ();
- DList <Contact> contactList = new List <Contact>(); for ( Contact c : [SELECT Id FROM Contact
How the community answered
(41 responses)- A10% (4)
- B2% (1)
- C83% (34)
- D5% (2)
Community Discussion
No community discussion yet for this question.