PDI · Question #183
PDI Question #183: Real Exam Question with Answer & Explanation
The correct answer is C: 10. After executing Apex code that first deletes all existing accounts and then inserts 10 new ones, the org will have a total of 10 accounts.
Question
A Developer Edition org has five existing accounts. A developer wants to add 10 more accounts for testing purposes. The following code is executed in the Developer Console using the Execute Anonymous window: How many total accounts will be in the org after this code is executed?
Options
- A5
- B6
- C10
- D15
Explanation
After executing Apex code that first deletes all existing accounts and then inserts 10 new ones, the org will have a total of 10 accounts.
Common mistakes.
- A. This implies that all accounts were deleted and none were successfully inserted, which contradicts the intent to add 10 accounts.
- B. This would mean an unspecified number of original accounts were deleted or not all 10 new accounts were inserted, which does not align with a clear test data setup pattern.
- D. This would mean the code only inserted the 10 new accounts without deleting the initial 5, resulting in 15 total accounts, not 10.
Concept tested. Apex DML operations (delete and insert) and transaction behavior
Reference. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_statements.htm
Topics
Community Discussion
No community discussion yet for this question.