Given a list of Opportunity records named opportunityList, which code snippet is best for querying all Contacts of the Opportunity's Account? A. ListcontactList = new List contactList = new List accountIds = new Set (); for (Opportunity o : opportunityList){ contactIds.add(o.ContactId); } for(Contact c : [SELECT Id FROM Contact WHERE Id IN :contactIds]){ contactList.add(c); } C. List contactList = new List accountIds = new Set (); for(Opportunity o : opportunityList){ accountIds.add(o.AccountId); } for(Account a : [SELECT Id, (SELECT Id FROM Contacts) FROM Account WHERE Id IN :accountIds]){ contactList.addAll(a.Contacts); } D. List contactList = new List Suggested Answer: C Community Answer: C This question is in Certified Platform Developer II Exam For getting Salesforce Certified Platform Developer II Disclaimers: The website is not related to, affiliated with, endorsed or authorized by Salesforce. Trademarks, certification & product names are used for reference only and belong to Salesforce. The website does not contain actual questions and answers from Salesforce's Certification Exams.
Please login or Register to submit your answer