PDI · Question #20
PDI Question #20: Real Exam Question with Answer & Explanation
The correct answer is A: The transaction will fail due to exceeding the governor limit.. When processing over 10,000 Case records in an anonymous block, the transaction will likely fail due to exceeding Salesforce governor limits, as LimitExceptions are uncatchable and cause transaction rollback.
Question
Given the following Anonymous Block: Which one do you like? What should a developer consider for an environment that has over 10,000 Case records?
Options
- AThe transaction will fail due to exceeding the governor limit.
- BThe try/catch block will handle any DML exceptions thrown.
- CThe transaction will succeed and changes will be committed.
- DThe try/catch block will handle exceptions thrown by governor limits.
Explanation
When processing over 10,000 Case records in an anonymous block, the transaction will likely fail due to exceeding Salesforce governor limits, as LimitExceptions are uncatchable and cause transaction rollback.
Common mistakes.
- B. While try/catch blocks can handle many types of Apex exceptions, they specifically cannot catch
LimitExceptionorSystem.LimitExceptionwhich are thrown when governor limits are exceeded. - C. A transaction attempting to modify or query over 10,000 records without proper batching or limits is almost guaranteed to hit governor limits and therefore will not succeed and commit changes.
- D. Try/catch blocks are ineffective against governor limit exceptions; these exceptions are uncatchable and lead to the immediate termination and rollback of the entire transaction.
Concept tested. Apex governor limits (DML, large data volumes)
Reference. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm
Topics
Community Discussion
No community discussion yet for this question.