PDI · Question #41
Refer to the following code snippet for an environment has more than 200 Accounts belonging to the Technology' industry: When the code execution, which two events occur as a result of the Apex…
The correct answer is A. If executed in an asynchronous context, the apex transaction is likely to fall by exceeding the. If the provided code snippet processing over 200 accounts is executed in an asynchronous context, it is likely to fail by exceeding Apex governor limits.
Question
Refer to the following code snippet for an environment has more than 200 Accounts belonging to the Technology' industry:
When the code execution, which two events occur as a result of the Apex transaction? When the code executes, which two events occur as a result of the Apex transaction? Choose 2 answers
Options
- AIf executed in an asynchronous context, the apex transaction is likely to fall by exceeding the
- BThe Apex transaction succeeds regardless of any uncaught exception and all processed accounts
- CThe Apex transaction fails with the following message. "SObject row was retrieved via SOQL
- DIf executed In a synchronous context, the apex transaction is likely to fall by exceeding the DHL
How the community answered
(25 responses)- A76% (19)
- B12% (3)
- C8% (2)
- D4% (1)
Why each option
If the provided code snippet processing over 200 accounts is executed in an asynchronous context, it is likely to fail by exceeding Apex governor limits.
Although asynchronous Apex contexts (like future methods or queueable jobs) offer higher limits for certain resources compared to synchronous Apex, if the code processes a large number of records like 200+ accounts in a single execution scope without proper batching, it can still exceed governor limits such as CPU time, heap size, or total SOQL query rows, causing the transaction to fail.
An Apex transaction will not succeed regardless of uncaught exceptions; uncaught exceptions will cause the transaction to roll back and fail, and any processed data will not be committed.
The message 'SObject row was retrieved via SOQL' is not a standard Apex transaction failure message, and specific failure messages vary based on the governor limit exceeded or the type of uncaught exception.
While a synchronous transaction processing a large number of records is very likely to fail due to hitting governor limits (e.g., DML statements or SOQL queries), choice A is the specific correct answer focusing on the potential for failure even in asynchronous contexts.
Concept tested: Apex Governor Limits in Asynchronous Contexts
Source: 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.