PDI · Question #44
Which Apex class contains methods to return the amount of resources that have been used for a particular governor, such as the number of DML statements?
The correct answer is D. Limits. The Limits Apex class provides methods for checking resource consumption against governor limits within the current transaction.
Question
Which Apex class contains methods to return the amount of resources that have been used for a particular governor, such as the number of DML statements?
Options
- AException
- BMessaging
- COrgLimits
- DLimits
How the community answered
(70 responses)- A3% (2)
- B1% (1)
- C7% (5)
- D89% (62)
Why each option
The `Limits` Apex class provides methods for checking resource consumption against governor limits within the current transaction.
The `Exception` class is part of Apex's error handling framework and is used to represent and manage runtime errors, not to monitor governor limit usage.
The `Messaging` class in Apex is used for sending email messages and other communication-related functionalities, unrelated to governor limit tracking.
While 'OrgLimits' is a concept related to platform limits, the specific Apex class for checking transaction-level governor limits during runtime is `Limits`, not `OrgLimits`.
The `Limits` Apex class offers static methods, such as `Limits.getDmlStatements()` or `Limits.getLimitDmlStatements()`, that allow developers to programmatically retrieve the number of resources consumed and the maximum allowable governor limits for the current Apex transaction.
Concept tested: Apex Limits Class for Governor Limits
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_limits.htm
Topics
Community Discussion
No community discussion yet for this question.