PDI · Question #196
How many Accounts will be inserted by the following block of code?
The correct answer is C. 0. The code attempts to insert accounts, but the DML operation results in 0 records being successfully inserted, likely due to an uninitialized list, an empty list, or a transaction-rolling-back DML exception.
Question
How many Accounts will be inserted by the following block of code?
Exhibit
Options
- A100
- B150
- C0
- D500
How the community answered
(53 responses)- A2% (1)
- B2% (1)
- C91% (48)
- D6% (3)
Why each option
The code attempts to insert accounts, but the DML operation results in 0 records being successfully inserted, likely due to an uninitialized list, an empty list, or a transaction-rolling-back DML exception.
This option implies a successful insertion of 100 accounts, which would not happen if the DML operation failed or was performed on an empty list.
This option implies a successful insertion of 150 accounts, which would not happen if the DML operation failed or was performed on an empty list.
Without the specific code, assuming a common scenario where a DML operation fails entirely due to a governor limit exception (e.g., too many SOQL queries or DML statements causing a rollback) or if the list intended for insertion is uninitialized (null) or empty, no accounts would be successfully inserted into the database.
This option implies a successful insertion of 500 accounts, which would not happen if the DML operation failed or was performed on an empty list.
Concept tested: Apex DML operations and governor limits
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dm_insert.htm
Topics
Community Discussion
No community discussion yet for this question.
