nerdexam
Salesforce

PDI · Question #33

What is the result of the following code?

The correct answer is C. The record will not be created and no error will be reported.. The result of the code is that the record will not be created and no exception will be thrown, indicating a DML operation was performed using the allOrNone = false parameter which suppresses exceptions for individual record failures.

Submitted by tunde_lagos· Apr 18, 2026Logic and Process Automation

Question

What is the result of the following code?

Options

  • AThe record will not be created and a exception will be thrown.
  • BThe record will be created and a message will be in the debug log.
  • CThe record will not be created and no error will be reported.
  • DThe record will be created and no error will be reported.

How the community answered

(49 responses)
  • A
    6% (3)
  • B
    2% (1)
  • C
    90% (44)
  • D
    2% (1)

Why each option

The result of the code is that the record will not be created and no exception will be thrown, indicating a DML operation was performed using the `allOrNone = false` parameter which suppresses exceptions for individual record failures.

AThe record will not be created and a exception will be thrown.

An exception would be thrown if the DML operation was performed without the `allOrNone = false` parameter (e.g., standard DML `insert record;`) and a failure occurred.

BThe record will be created and a message will be in the debug log.

If the record fails creation, it will not be created; while a message might appear in the debug log if an exception is caught and logged, the core outcome is non-creation due to failure.

CThe record will not be created and no error will be reported.Correct

When using `Database.insert(recordList, false)`, if a record fails validation or other database constraints, it will not be inserted, but the operation will continue for other records (if any), and no unhandled exception will be thrown, resulting in 'no error reported' to the caller.

DThe record will be created and no error will be reported.

The record will not be created if there's a DML failure; the outcome of 'record created' contradicts the scenario implied by 'no error reported' for a failing DML operation with `allOrNone=false`.

Concept tested: DML operations with partial success / error handling

Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_database_dml_options.htm

Topics

#DML Operations#Error Handling#Apex DML#Database Class

Community Discussion

No community discussion yet for this question.

Full PDI Practice