nerdexam
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)
  • A
    10% (4)
  • B
    2% (1)
  • C
    83% (34)
  • D
    5% (2)

Community Discussion

No community discussion yet for this question.

Full PDII Practice