Salesforce Platform Developer I (legacy) — Question 172
Which two statements are true about Apex code executed in Anonymous Blocks? (Choose two.)
Answer options
- A. The code runs with the permissions of the user specified in the runAs() statement.
- B. The code runs with the permissions of the logged in user.
- C. The code runs in system mode having access to all objects and fields.
- D. All DML operations are automatically rolled back.
- E. Successful DML operations are automatically committed.
Correct answer: B, E
Explanation
The correct answers are B and E because Apex code in Anonymous Blocks runs with the permissions of the logged-in user and successful DML operations are committed automatically. Options A and C are incorrect as they do not apply when executing in Anonymous Blocks, while D is false because DML operations are not rolled back unless specifically coded to do so.