Apex Mock Exam 2: Architectural Patterns, Advanced Integration, Performance Optimization, and
Security Governance
Instructions:
This exam consists of 150 multiple-choice questions.
Each question has four options (A, B, C, D).
Choose the single best answer for each question.
Time allocation is 180 minutes (3 hours).
Passing score is 70%.
Section 1: Core Apex & Governor Limits (Questions 1-25)
1. A developer writes a batch Apex class to process 50 million records. The execute method queries
for related records using a Map<Id, List<SObject>> . During testing, the job fails with a
System.HeapException . Which two actions could resolve this? (Choose 2)
A. Increase the heap size in the Salesforce org settings.
B. Reduce the batch scope size in the Database.executeBatch method.
C. Implement Database.stateful to offload data to the platform cache.
D. Use Iterable instead of QueryLocator to stream data.
E. Use a Database.getQueryLocator with a SOQL query that filters data more effectively in the start
method.
Correct Answer: B, E
Rationale: The heap size is a fixed governor limit (6 MB for synchronous, 12 MB for asynchronous). You
cannot increase it (A). While Database.stateful allows state retention, it doesn't offload heap
memory to the cache automatically; you would need to use Cache.Org explicitly. Iterable doesn't
solve heap issues if the data is still loaded into memory. Reducing batch scope (B) reduces the number
of records processed per execute chunk, lowering heap usage. Filtering data in the start query (E)
ensures only necessary data is processed, reducing the heap footprint per batch.
2. In a highly concurrent Salesforce org, a trigger on the Account object calls an @future method
that performs a callout to an external system. Under heavy load, users report that the callout is not
occurring for some records. What is the most likely cause?
A. The @future method is hitting the daily limit for asynchronous calls.
B. The callout is failing due to a timeout, and the exception is being swallowed.
C. The @future method is being queued and is hitting the concurrent Apex limit for long-running
requests.
D. The trigger is exceeding the maximum SOQL query rows limit.
,Correct Answer: C
Rationale: In a high-concurrency scenario, the Apex scheduler queue can become backlogged.
Salesforce limits the number of concurrent asynchronous Apex jobs (e.g., @future methods) that can
run simultaneously (up to 100 in a 24-hour period, but also a max of 50 concurrent batch/future jobs
per org). If many @future methods are queued, they may sit in the queue and potentially be delayed
or throttled. While (A) could be a cause (250,000 future calls per 24 hours), the scenario implies it's
happening "under heavy load," making concurrent limit saturation more likely. The issue is with
execution, not the trigger query, so (D) is irrelevant.
3. Which statement about the System.AsyncException is true?
A. It is thrown when a synchronous transaction exceeds the heap size limit.
B. It is thrown when a batch job fails to finish within the 24-hour batch window.
C. It is thrown when an asynchronous method (like @future ) cannot be enqueued due to the queue
being full.
D. It is a runtime exception that is thrown when a scheduled job is aborted by an administrator.
Correct Answer: C
Rationale: AsyncException is specifically thrown when there's a problem with the asynchronous
processing framework, such as the queue being full for future methods or batch jobs. (A) is
HeapException , (B) is a generic batch failure (though might cause a LimitException ), and (D) is a
System.CalloutException or related to scheduler management.
4. A developer is using a List<SObject> and needs to perform a DML operation. To minimize the
number of DML statements and avoid hitting the "Maximum number of DML statements (150)"
limit, what is the best practice?
A. Use Database.insert(recordList, false) to allow partial success.
B. Use List<SObject> with a for loop to insert records one by one.
C. Use Database.insert(recordList, true) .
D. Use SObject addError() to prevent the DML statement from running.
Correct Answer: A
Rationale: Using Database.insert(recordList, false) (or Database.insert(recordList, true) )
performs a bulk DML operation, which counts as a single DML statement against the 150 limit,
regardless of the list size. Option (B) would hit the limit very quickly. Option (C) does the same as A,
but false is preferred for handling partial failures without the entire transaction rolling back,
providing better control and error handling, which is often a best practice for advanced solutions.
Option (D) is incorrect.
,5. A developer is writing a Visualforce page that makes an AJAX request to a custom Apex REST
endpoint. The endpoint method is annotated with @RestResource(urlMapping='/myEndpoint/*') .
The method processes the request and returns data. What is the maximum response size for this
REST call in Salesforce?
A. 3 MB
B. 6 MB
C. 12 MB
D. 15 MB
Correct Answer: A
Rationale: The maximum response size for a synchronous Apex REST callout is 3 MB for the response
body. Inbound synchronous requests (like REST API calls to Salesforce) have a limit of 6 MB for the
request body, but the response from a custom REST endpoint is limited to 3 MB.
6. A developer is implementing a complex business logic that requires processing a List<Account>
in a trigger. The logic involves multiple nested for loops and string manipulations. Which
governor limit is the developer most likely to hit first?
A. CPU Time Limit
B. SOQL Query Rows Limit
C. Heap Size Limit
D. Maximum Trigger Depth (16)
Correct Answer: A
Rationale: Complex business logic, especially with nested loops and heavy string manipulation, is
computationally intensive. The CPU time limit is a hard governor (10 ms for synchronous contexts,
60,000 ms for asynchronous). While heap and query rows are possible, "complex business logic" with
nested loops heavily implies a CPU issue. (D) refers to recursion, not general processing.
7. Which of the following is NOT a valid way to pass parameters to a @future method?
A. @future public static void myFutureMethod(String param1, Integer param2)
B. @future public static void myFutureMethod(Id recordId)
C. @future public static void myFutureMethod(List<Id> recordIds)
D. @future public static void myFutureMethod(Account acc)
Correct Answer: D
Rationale: @future methods only accept primitive data types, collections of primitives, and Id types
(which are effectively strings). Passing an entire sObject (like Account ) is not allowed because it
wouldn't be serializable for the queue. You should pass the Id of the record and query it again in the
async context.
, 8. In a trigger, you need to make a callout to an external system. Which of the following is the most
appropriate design pattern?
A. Use @future(callout=true) in the trigger to make the callout asynchronously.
B. Make the callout directly in the trigger using HttpRequest and HttpResponse .
C. Use a Queueable Apex class with callout=true .
D. Use a Batch Apex class with callout=true .
Correct Answer: A
Rationale: Triggers are synchronous and cannot perform callouts directly. The only standard way to
make a callout from a trigger is to use an @future method with callout=true . While Queueable can
also make callouts, it is asynchronous; @future is the most direct and commonly used approach in
this scenario. (C) is correct but less direct for a trigger, and the prompt asks for the most appropriate.
9. What is the significance of the @AuraEnabled annotation on an Apex method?
A. It allows the method to be used in Lightning Web Components and Aura Components.
B. It allows the method to be used in a Batch Apex job.
C. It allows the method to be exposed as a RESTful web service.
D. It allows the method to be scheduled using the Scheduler.
Correct Answer: A
Rationale: @AuraEnabled is used to expose Apex methods to the Lightning Component framework
(both Aura and LWC). (B) is for the Database.Batchable interface, (C) is @RestResource, and (D) is
Schedulable.
10. A developer is using an @InvocableMethod to allow a Flow to call Apex. The method accepts a
List<Request> where Request is an inner class with @InvocableVariable annotations. What is a
key best practice for this method?
A. It should be public static and return void .
B. It should be public and return a List<Response> .
C. It should be public static and accept a List<List<Request>> to support bulk execution.
D. It should be private and accept a single Request object.
Correct Answer: C
Rationale: @InvocableMethod must be public static . To support bulk processing (best practice for
performance), the method should accept a List<List<T>> where the outer list represents the
invocations and the inner list is the collection of variables to be processed. This allows the Flow to pass
multiple records in a single call.
Security Governance
Instructions:
This exam consists of 150 multiple-choice questions.
Each question has four options (A, B, C, D).
Choose the single best answer for each question.
Time allocation is 180 minutes (3 hours).
Passing score is 70%.
Section 1: Core Apex & Governor Limits (Questions 1-25)
1. A developer writes a batch Apex class to process 50 million records. The execute method queries
for related records using a Map<Id, List<SObject>> . During testing, the job fails with a
System.HeapException . Which two actions could resolve this? (Choose 2)
A. Increase the heap size in the Salesforce org settings.
B. Reduce the batch scope size in the Database.executeBatch method.
C. Implement Database.stateful to offload data to the platform cache.
D. Use Iterable instead of QueryLocator to stream data.
E. Use a Database.getQueryLocator with a SOQL query that filters data more effectively in the start
method.
Correct Answer: B, E
Rationale: The heap size is a fixed governor limit (6 MB for synchronous, 12 MB for asynchronous). You
cannot increase it (A). While Database.stateful allows state retention, it doesn't offload heap
memory to the cache automatically; you would need to use Cache.Org explicitly. Iterable doesn't
solve heap issues if the data is still loaded into memory. Reducing batch scope (B) reduces the number
of records processed per execute chunk, lowering heap usage. Filtering data in the start query (E)
ensures only necessary data is processed, reducing the heap footprint per batch.
2. In a highly concurrent Salesforce org, a trigger on the Account object calls an @future method
that performs a callout to an external system. Under heavy load, users report that the callout is not
occurring for some records. What is the most likely cause?
A. The @future method is hitting the daily limit for asynchronous calls.
B. The callout is failing due to a timeout, and the exception is being swallowed.
C. The @future method is being queued and is hitting the concurrent Apex limit for long-running
requests.
D. The trigger is exceeding the maximum SOQL query rows limit.
,Correct Answer: C
Rationale: In a high-concurrency scenario, the Apex scheduler queue can become backlogged.
Salesforce limits the number of concurrent asynchronous Apex jobs (e.g., @future methods) that can
run simultaneously (up to 100 in a 24-hour period, but also a max of 50 concurrent batch/future jobs
per org). If many @future methods are queued, they may sit in the queue and potentially be delayed
or throttled. While (A) could be a cause (250,000 future calls per 24 hours), the scenario implies it's
happening "under heavy load," making concurrent limit saturation more likely. The issue is with
execution, not the trigger query, so (D) is irrelevant.
3. Which statement about the System.AsyncException is true?
A. It is thrown when a synchronous transaction exceeds the heap size limit.
B. It is thrown when a batch job fails to finish within the 24-hour batch window.
C. It is thrown when an asynchronous method (like @future ) cannot be enqueued due to the queue
being full.
D. It is a runtime exception that is thrown when a scheduled job is aborted by an administrator.
Correct Answer: C
Rationale: AsyncException is specifically thrown when there's a problem with the asynchronous
processing framework, such as the queue being full for future methods or batch jobs. (A) is
HeapException , (B) is a generic batch failure (though might cause a LimitException ), and (D) is a
System.CalloutException or related to scheduler management.
4. A developer is using a List<SObject> and needs to perform a DML operation. To minimize the
number of DML statements and avoid hitting the "Maximum number of DML statements (150)"
limit, what is the best practice?
A. Use Database.insert(recordList, false) to allow partial success.
B. Use List<SObject> with a for loop to insert records one by one.
C. Use Database.insert(recordList, true) .
D. Use SObject addError() to prevent the DML statement from running.
Correct Answer: A
Rationale: Using Database.insert(recordList, false) (or Database.insert(recordList, true) )
performs a bulk DML operation, which counts as a single DML statement against the 150 limit,
regardless of the list size. Option (B) would hit the limit very quickly. Option (C) does the same as A,
but false is preferred for handling partial failures without the entire transaction rolling back,
providing better control and error handling, which is often a best practice for advanced solutions.
Option (D) is incorrect.
,5. A developer is writing a Visualforce page that makes an AJAX request to a custom Apex REST
endpoint. The endpoint method is annotated with @RestResource(urlMapping='/myEndpoint/*') .
The method processes the request and returns data. What is the maximum response size for this
REST call in Salesforce?
A. 3 MB
B. 6 MB
C. 12 MB
D. 15 MB
Correct Answer: A
Rationale: The maximum response size for a synchronous Apex REST callout is 3 MB for the response
body. Inbound synchronous requests (like REST API calls to Salesforce) have a limit of 6 MB for the
request body, but the response from a custom REST endpoint is limited to 3 MB.
6. A developer is implementing a complex business logic that requires processing a List<Account>
in a trigger. The logic involves multiple nested for loops and string manipulations. Which
governor limit is the developer most likely to hit first?
A. CPU Time Limit
B. SOQL Query Rows Limit
C. Heap Size Limit
D. Maximum Trigger Depth (16)
Correct Answer: A
Rationale: Complex business logic, especially with nested loops and heavy string manipulation, is
computationally intensive. The CPU time limit is a hard governor (10 ms for synchronous contexts,
60,000 ms for asynchronous). While heap and query rows are possible, "complex business logic" with
nested loops heavily implies a CPU issue. (D) refers to recursion, not general processing.
7. Which of the following is NOT a valid way to pass parameters to a @future method?
A. @future public static void myFutureMethod(String param1, Integer param2)
B. @future public static void myFutureMethod(Id recordId)
C. @future public static void myFutureMethod(List<Id> recordIds)
D. @future public static void myFutureMethod(Account acc)
Correct Answer: D
Rationale: @future methods only accept primitive data types, collections of primitives, and Id types
(which are effectively strings). Passing an entire sObject (like Account ) is not allowed because it
wouldn't be serializable for the queue. You should pass the Id of the record and query it again in the
async context.
, 8. In a trigger, you need to make a callout to an external system. Which of the following is the most
appropriate design pattern?
A. Use @future(callout=true) in the trigger to make the callout asynchronously.
B. Make the callout directly in the trigger using HttpRequest and HttpResponse .
C. Use a Queueable Apex class with callout=true .
D. Use a Batch Apex class with callout=true .
Correct Answer: A
Rationale: Triggers are synchronous and cannot perform callouts directly. The only standard way to
make a callout from a trigger is to use an @future method with callout=true . While Queueable can
also make callouts, it is asynchronous; @future is the most direct and commonly used approach in
this scenario. (C) is correct but less direct for a trigger, and the prompt asks for the most appropriate.
9. What is the significance of the @AuraEnabled annotation on an Apex method?
A. It allows the method to be used in Lightning Web Components and Aura Components.
B. It allows the method to be used in a Batch Apex job.
C. It allows the method to be exposed as a RESTful web service.
D. It allows the method to be scheduled using the Scheduler.
Correct Answer: A
Rationale: @AuraEnabled is used to expose Apex methods to the Lightning Component framework
(both Aura and LWC). (B) is for the Database.Batchable interface, (C) is @RestResource, and (D) is
Schedulable.
10. A developer is using an @InvocableMethod to allow a Flow to call Apex. The method accepts a
List<Request> where Request is an inner class with @InvocableVariable annotations. What is a
key best practice for this method?
A. It should be public static and return void .
B. It should be public and return a List<Response> .
C. It should be public static and accept a List<List<Request>> to support bulk execution.
D. It should be private and accept a single Request object.
Correct Answer: C
Rationale: @InvocableMethod must be public static . To support bulk processing (best practice for
performance), the method should accept a List<List<T>> where the outer list represents the
invocations and the inner list is the collection of variables to be processed. This allows the Flow to pass
multiple records in a single call.