exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 276 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 276
Topic #: 1
[All Certified Platform Developer II Questions]

Refer to the code snippet below:



As part of an integration development effort, a developer is tasked to create an Apex method that solely relies on the use of foreign identifiers in order to relate new contact records to existing Accounts in Salesforce. The account object contains a field marked as an external ID, the API Name of this field is Legacy_Id_c.

What is the most efficient way to instantiate the parentAccount variable on line 02 to ensure the newly created contact is properly related to the Account?

  • A. Account parentAccount = new Account(Legacy_Id_c = externalIdentifier);
  • B. Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier].Id;
  • C. Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier];
  • D. Account parentAccount = new Account();
    parentAccount.Id = externalIdentifier;
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
BrucePark
Highly Voted 2 years ago
Selected Answer: A
This is A. I tested it.
upvoted 5 times
M4JK3LSON
1 year, 7 months ago
A creates new Account instance but question iclude information, that we use scope of EXISITNG ACCOUNTS
upvoted 1 times
...
...
doni10
Most Recent 9 months, 1 week ago
i think it is C because newContact.Account expect an account with the right id to be linked, the external id even if it is uniq (that is not forced) will not be sufficient to link the two object it is not a standard behavior to link two object with other thing that an id
upvoted 1 times
...
true_dev
10 months, 2 weeks ago
A. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_nested_object.htm
upvoted 2 times
...
FriedConsole2000
1 year, 5 months ago
Selected Answer: C
It is C
upvoted 1 times
...
Sapphire808
1 year, 10 months ago
Selected Answer: C
C. Both A and D create a new parent account, which is not needed since the account is already in the system as stated by the question. Therefore that leaves B and C. It cannot be B because that does not follow proper formatting and assignment rules, plus the Id is already indicated as the field to get from the SOQL query. That means the answer is C.
upvoted 1 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 ...