Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
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 122 discussion

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

Employee_c is a Child object of Company_c. The Company_c object has an external Id field Company_Id_c.
How can a developer insert an Employee_c record linked to Company_c with a Company_Id_c of '999'?

  • A. Employee_c emp = new Employee_c(Name='Developer'); emp.Company_r = '999' insert emp;
  • B. Employee_c emp = new Employee_c(Name='Developer'); emp.Company_c = '999' insert emp;
  • C. Employee_c emp = new Employee_c(Name='Developer'); emp. Company_c = new Company_c(Company_Id_c='999') insert emp;
  • D. Employee_c emp = new Employee_c(Name='Developer'); emp.Company_r = new Company_r(Company_Id_c='999') insert emp;
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
beardAnt
1 month, 1 week ago
Selected Answer: C
As they are, none of them are correct, so if a typo is fixed, C seems to be the correct one: Employee__c emp = new Employee__c(Name='Developer X'); [emp.Company__r = new Company__c(Company_Id__c='999');] insert emp;
upvoted 1 times
...
sf2022
1 year, 11 months ago
Fix the typo of given answers or none of them are correct
upvoted 2 times
...
mageshrr
2 years ago
Employee__c emp = new Employee__c(Name='Developer'); Company__r = new Company__c(Company_Id__c ='999'); insert emp; The above code works fine, therefore, all the given answers were not correct, it seems.
upvoted 1 times
...
Liquad
3 years, 2 months ago
Employee_c emp = new Employee_c(Name='Developer'); emp. Company_r = new Company_c(Company_Id_c='999'); insert emp;
upvoted 3 times
...
Hello_Sfdc
3 years, 8 months ago
In option D, Company_r(Company_Id_c='999') it should be Company__c to work. In Option C, emp.Company_c = new Company_c(Company_Id_c='999') it should be emp.Company_r on LHS for it to work.
upvoted 2 times
...
NiuNiuG
3 years, 9 months ago
C https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_nested_object.htm
upvoted 3 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 ...