When using a @future method, what data type is allowed as a parameter?
Primitive types like String are supported.
Why this answer
Future methods only accept primitive data types or collections of primitive data types.
70 of 145 questions · Page 2/2 · Process Automation And Logic · Answers revealed
When using a @future method, what data type is allowed as a parameter?
Primitive types like String are supported.
Why this answer
Future methods only accept primitive data types or collections of primitive data types.
A developer is designing a complex data validation and transformation process. Which TWO scenarios are best implemented using an Apex Trigger rather than a Record-Triggered Flow? (Choose TWO.)
Heavy programmatic logic and custom wrapper classes require Apex.
Why this answer
Apex triggers excel at complex integrations (callouts) and custom exception handling across multiple distinct object hierarchies that exceed declarative flow capabilities.
Which feature allows administrators to invoke an Apex method from a Flow?
@InvocableMethod allows Apex code to be called directly from flows.
Why this answer
The @InvocableMethod annotation exposes Apex methods to flows and process builder.
During the Salesforce order of execution, when are validation rules evaluated relative to before triggers?
Correct. Validation rules run immediately after before triggers finish executing.
Why this answer
Validation rules execute after the 'before' triggers have completed and modified the records, ensuring that the validated state reflects any programmatic field updates.
A developer has written a trigger on the Account object that performs a SOQL query inside a for-loop. The developer notices that when a data load of 200 records occurs, governor limits are exceeded. What is the most efficient way to refactor this trigger?
Correct. Collecting IDs into a Set and querying once using the IN clause avoids hitting SOQL governor limits.
Why this answer
To avoid SOQL query limits, queries should be moved outside of loops and leverage collections (lists or sets) to retrieve all required data in a single query.
A developer needs to write a test class for a Batch Apex job. Which method must be called to verify that the batch job executes correctly?
Enclosing Database.executeBatch between startTest and stopTest ensures the batch executes synchronously during the test.
Why this answer
Database.executeBatch inside Test.startTest() and Test.stopTest() executes the batch job in test context.
Which TWO tools or features should a developer consider when choosing between Flow Builder and Apex for business logic automation? (Choose two.)
Apex provides full object-oriented programming capabilities for complex logic and custom libraries.
Why this answer
Flow Builder is declarative and reduces maintenance, while Apex handles complex algorithms, batching, and high-volume triggers.
Which THREE actions can cause a governor limit exception during a poorly optimized trigger execution? (Choose three.)
Large data collections exceed the 6 MB synchronous heap limit.
Why this answer
Queries in loops, too many DML statements, and excessive heap size allocation trigger governor limit exceptions.
What is the maximum number of asynchronous batch jobs that can be queued or active concurrently in the Flex Queue?
The Flex Queue holds up to 100 batch jobs in a Holding status.
Why this answer
Salesforce allows up to 100 batch jobs to be placed in the holding queue (Flex Queue) waiting for execution.
A developer needs to update a related record. If using Apex, what is the best practice to avoid hitting governor limits?
Bulkification is essential for efficient Apex.
Why this answer
Bulkify the code to perform operations on collections rather than individual records.
A developer wants to schedule an Apex class to run daily. Which interface must the class implement?
Schedulable allows the execution of code at specific times.
Why this answer
The Schedulable interface is required for classes that need to be scheduled.
Which THREE trigger context variables are available ONLY in insert and update triggers (not delete triggers)? (Choose THREE.)
Trigger.newMap is available on insert (after) and update.
Why this answer
Trigger.new, Trigger.newMap, and Trigger.oldMap are available in insert/update contexts (oldMap is update only, new/newMap are insert/update). Let's check exact availability: Trigger.new and Trigger.newMap are available on insert and update (and undelete for new). Trigger.old and Trigger.oldMap are available on update and delete.
Let's frame the question around variables available in Trigger insert/update events vs delete.
Which TWO statements are true regarding Queueable Apex compared to future methods? (Choose two.)
Correct. System.enqueueJob returns an ID for tracking.
Why this answer
Queueable Apex offers job IDs for tracking and supports complex data types, unlike future methods.
What is the maximum number of asynchronous Apex jobs that can be queued in a 24-hour period in a Developer Edition org?
250,000 is the correct limit for Developer Edition.
Why this answer
The limit is 250,000 asynchronous Apex method executions per 24-hour period.
When should a developer choose to implement Schedulable Apex? (Choose two.)
Correct. Schedulable Apex is commonly used to invoke batch jobs periodically.
Why this answer
Schedulable Apex is used to run Apex classes at scheduled times or intervals, such as nightly batch jobs or periodic maintenance tasks.
A developer has a requirement to perform a callout to an external ERP system immediately when an Opportunity reaches Closed Won. The developer decides to use a future method from an after update trigger. What is a primary architectural limitation of this approach?
Because future methods only accept primitives, the future method must requery records using passed IDs.
Why this answer
Future methods cannot accept sObjects as arguments, requiring the trigger to pass primitive IDs, and they cannot guarantee exact execution order when multiple asynchronous requests fire.
Which interface enables an Apex class to be invoked from a Flow using the InvocableAction framework?
Invocable actions are defined via the @InvocableMethod annotation rather than implementing a specific interface.
Why this answer
Methods annotated with @InvocableMethod allow Apex to be called from declarative flows.
An enterprise application requires real-time integration where outgoing callouts must be triggered from an Apex trigger. What architectural pattern must the developer use?
Asynchronous future methods with callout=true allow web service requests from triggers safely.
Why this answer
Triggers cannot make direct synchronous callouts, so they must invoke an asynchronous mechanism like a future method with callout=true.
Which TWO of the following are valid ways to chain asynchronous Apex?
This is the standard way to chain jobs.
Why this answer
Queueable Apex and Scheduled Apex allow for chaining or subsequent scheduling.
Which THREE of the following are valid uses for the Database.executeBatch method parameters?
The constructor is used for passing data.
Why this answer
The method allows setting the batch size, which is critical for performance tuning.
Which THREE limitations apply to @future methods?
Only primitives are allowed.
Why this answer
Future methods cannot be tracked, have specific parameter limits, and cannot be chained.
A Queueable Apex job implements Database.AllowsCallouts and chains another Queueable job. What is the maximum number of jobs that can be chained in a single transaction chain?
In developer and enterprise editions, the maximum chain depth for Queueable jobs is 5.
Why this answer
Queueable jobs can be chained, but only one child job can be spawned per execution, up to a maximum depth limit of 5 in a synchronous transaction chain (or more depending on async chains, but standard chaining depth is limited).
A developer is writing a Queueable class that needs to make a callout and also perform a DML operation afterward in the same transaction. Which interface must be added to the Queueable class definition?
Implementing Database.AllowsCallouts permits HTTP callouts from asynchronous Queueable executions.
Why this answer
To make HTTP callouts in Queueable Apex, the class must implement the Database.AllowsCallouts interface.
A developer creates an Apex trigger that updates related Contact records whenever an Account record is updated. The trigger performs a DML operation on the Contacts. During testing, updating an Account causes the trigger to fire infinitely and throw a System.LimitException: Maximum trigger depth exceeded. Which design pattern should the developer implement to prevent this recursion?
Correct. A static variable retains its value for the duration of the request, allowing the code to check if it has already executed.
Why this answer
Using a static boolean flag in a helper class is the standard Salesforce pattern to prevent recursive trigger execution by tracking whether the trigger logic has already run in the current transaction.
A developer needs to ensure that an Apex trigger fires only during the after insert context. Which check should be placed at the beginning of the trigger body?
This condition correctly targets after insert events.
Why this answer
Checking Trigger.isAfter and Trigger.isInsert ensures the code runs only during the desired trigger event.
A developer has a requirement to update child Case records whenever a parent Account's status changes. The logic requires complex looping, exception handling, and handling up to 10,000 related records. Which tool should the developer choose according to Salesforce best practices?
Apex triggers provide robust control, bulkification, and error-handling capabilities for complex enterprise logic.
Why this answer
Apex Triggers combined with Batch Apex or bulkified code are ideal for complex business logic involving high-volume child record updates that exceed declarative flow limits.
Which TWO tools are effective for monitoring asynchronous Apex jobs?
This shows all async jobs.
Why this answer
The Apex Jobs page and the AsyncApexJob object are primary monitoring tools.
Which best practice should be followed when writing Apex triggers to ensure bulkification?
Bulkification ensures that triggers handle any number of records passed via data loader or UI seamlessly.
Why this answer
Triggers must be written to handle collections of records (Trigger.new / Trigger.old) rather than single records.
During the Salesforce save order of execution, when are before triggers executed relative to custom validation rules?
Before triggers run prior to validation rules so values can be normalized or prepopulated.
Why this answer
Before triggers execute before custom validation rules are evaluated, allowing developers to modify field values before validation checks run.
A developer needs to ensure that a specific Apex method runs asynchronously because it makes a callout to an external REST API from a standard user interface controller. Which annotation must be added to the method?
Correct. The @future annotation with callout=true enables asynchronous execution and allows callouts.
Why this answer
The @future(callout=true) annotation allows an Apex method to run asynchronously and enables it to perform HTTP callouts.
Which THREE statements are true regarding asynchronous Apex governor limits and execution behavior? (Choose three.)
Each asynchronous execution runs in a fresh transaction with reset limits.
Why this answer
Asynchronous jobs have higher limits (heap, CPU time), run in separate transactions, and can be monitored via AsyncApexJob.
A developer has a trigger that updates related child records. To prevent recursive trigger execution when updates ripple through child triggers, what is a standard best practice design pattern?
A static boolean flag set to true after first execution prevents subsequent recursive triggers from running.
Why this answer
Using a static boolean flag in a helper class is the classic pattern to prevent recursive trigger execution in Salesforce.
A developer is troubleshooting a transaction that exceeds governor limits due to SOQL queries. Which THREE techniques help prevent hitting SOQL query limits in Apex? (Choose THREE.)
In-memory map lookups eliminate repetitive SOQL queries inside loops.
Why this answer
Avoiding queries in loops, using aggregate queries, and caching results in maps/collections help avoid SOQL query limit issues.
A developer implements a Schedulable class to run a daily cleanup job. What is the maximum number of scheduled Apex jobs that can be simultaneously active in an org?
Salesforce limits the number of scheduled Apex jobs in an org to 100.
Why this answer
Salesforce enforces a strict limit of 100 simultaneous scheduled Apex jobs per org.
When a record-triggered flow performs an action that causes a trigger to fire, which order of execution phase is this?
Salesforce re-enters the order of execution.
Why this answer
This is part of the re-entrant execution, where Salesforce processes the trigger as part of the flow's transaction.
Which context variable should a developer use in an Apex trigger to determine if the trigger was fired by an update operation rather than an insert?
Trigger.isUpdate is the correct boolean context variable for update operations.
Why this answer
Trigger.isUpdate returns true if the trigger was fired due to an update operation.
A developer is troubleshooting an Apex trigger recursion issue where an update operation triggers itself infinitely. Which THREE strategies can the developer use to safely prevent this recursion? Choose 3 options.
Dynamic kill-switches allow administrators or developers to disable faulty or recursive triggers instantly.
Why this answer
Trigger recursion can be prevented using static boolean flags in a helper class, utilizing trigger context maps to check if specific fields actually changed, or leveraging custom metadata/settings to disable triggers dynamically.
A developer encounters a 'System.AsyncException: Maximum queueable jobs added to the queue' error. What caused this exception?
Adding more than 50 queueable jobs in a single transaction throws this exception.
Why this answer
Exceeding the limit of 50 queued jobs added to the flex queue in a single transaction triggers this AsyncException.
Which governor limit applies to the total CPU time in a single synchronous Apex transaction?
10,000 ms is the synchronous CPU time limit.
Why this answer
The synchronous CPU time limit is 10,000 milliseconds (10 seconds).
A developer is implementing a Batch Apex class to process 500,000 Contact records. Which method defines the starting point and retrieves the records to be processed?
QueryLocator is the standard and most efficient way to fetch records for batch processing.
Why this answer
The start method of a Database.Batchable class returns either a Database.QueryLocator or an Iterable that defines the records to be processed.
A developer needs to chain asynchronous jobs. Which interface allows for a single job to be queued from within the execution of another?
Queueable Apex supports chaining through System.enqueueJob.
Why this answer
Queueable Apex allows for chaining jobs by calling System.enqueueJob within the execute method.
Which trigger context variable should a developer use to access the map of old record versions prior to the update operation?
Correct. Trigger.oldMap is a map of IDs to the old version of the SObject records.
Why this answer
Trigger.oldMap provides a map of IDs to the old versions of the SObject records for update and delete triggers.
When should a developer use a record-triggered flow instead of a scheduled path in a flow?
Immediate record-triggered flows run synchronously right when the record is saved.
Why this answer
Record-triggered flows execute immediately upon record creation or update, whereas scheduled paths run at a specific time offset.
A developer implements a Batch Apex class that updates millions of records. During the execution of the execute method, a transient database error occurs on a single record. What happens to the batch job by default if Database.executeBatch is called without additional parameters?
Correct. Uncaught exceptions in a batch execution cause the transaction to fail and the entire batch job to be marked as Failed.
Why this answer
By default, if an unhandled exception occurs in a batch chunk, the entire batch job fails and the error is logged, unless Database.insert is used with allOrNone set or exception handling is implemented.
When should a developer choose a Record-Triggered Flow over an Apex trigger for automating record updates before save?
Correct. Before-save flows run significantly faster than Apex triggers and provide declarative maintainability.
Why this answer
Before-save record-triggered flows execute faster than Apex before-triggers and are fully declarative, making them the preferred choice for same-record field updates.
Which trigger event handles the restoration of records from the Recycle Bin?
Salesforce provides before undelete and after undelete trigger events for restored records.
Why this answer
Undelete triggers handle records restored from the recycle bin.
A developer needs to abort a scheduled Apex job programmatically from within a test class or maintenance script. Which method should be used?
System.abortJob takes the job ID of a scheduled or flex-queue job to stop it.
Why this answer
System.abortJob(jobId) cancels a scheduled or flex-queued asynchronous job.
Which TWO best practices should developers follow when implementing Queueable Apex chaining? (Choose two.)
Each chained job runs in a new transaction, requiring proper bulkification and limit management.
Why this answer
Chaining queueable jobs should be conditional to avoid infinite loops and should monitor flex queue limits.
An Apex trigger needs to update fields on the same record that is currently being inserted in a Before Insert trigger context. How should the developer implement this update?
Before trigger context allows direct modification of record fields in Trigger.new without DML statements.
Why this answer
In a before insert trigger, records are already in memory and have not yet been saved to the database. Developers can modify fields directly on the Trigger.new records without calling an explicit DML operation.
A developer writes an Apex trigger that performs a DML operation on Account records. The Account has a Roll-Up Summary field calculated from child Contact records. What happens during the order of execution regarding roll-up summary field calculations?
Parent roll-ups update after child changes, subsequently firing parent rules and triggers.
Why this answer
Roll-up summary fields are recalculated by Salesforce after DML operations on child records and before the transaction completes, triggering parent rules.
Which TWO actions are valid best practices when writing robust Batch Apex classes to adhere to governor limits and maintain data integrity? Choose 2 options.
Database.Stateful preserves member variable values across transactions, but should only be used when necessary as it impacts performance and memory.
Why this answer
Batch Apex classes should utilize Database.getQueryLocator for large datasets to avoid heap size limits, and stateful tracking should be minimized unless specifically required to track aggregate metrics across batches.
A batch Apex class processes 50,000 records. During the execute method, a custom governor limit is approached. Which method can the developer call to check the remaining CPU time dynamically?
Limits.getCpuTime() returns the CPU time consumed so far in the current transaction.
Why this answer
Limits.getLimitCpuTime() and Limits.getCpuTime() allow developers to monitor resource usage dynamically.
A developer is building a solution that requires complex branching logic. When should the developer choose Apex over Flow?
Apex provides a more robust environment for complex procedural logic.
Why this answer
Apex should be used when complex logic is required that cannot be represented in the Flow canvas, such as complex loops or high-performance algorithms.
Which TWO of the following statements about Trigger.new and Trigger.old are accurate?
It holds the old version of records.
Why this answer
Trigger.new is always present on insert/update; Trigger.old is always present on update/delete.
Which trigger context variable returns a map of IDs to the new versions of the sObject records?
Trigger.newMap provides a keyed lookup of records by ID for the new state.
Why this answer
Trigger.newMap contains the map of IDs to the new versions of the sObject records, available only in update, undelete, and after insert contexts.
A developer needs to schedule an Apex class to run weekly. Which syntax correctly schedules the job using System.schedule?
Correct. This provides the job name, valid CRON string, and class instance.
Why this answer
System.schedule requires a job name, a valid CRON expression, and an instance of the Schedulable class.
Which tool is best for automating a process that requires UI interaction, such as a wizard screen?
Screen flows are specifically for user interaction.
Why this answer
Flows provide the Screen component for user-interactive processes.
During the Salesforce order of execution, which THREE actions occur AFTER the system executes 'after' triggers? (Choose three.)
Correct. Assignment rules execute after after-triggers.
Why this answer
After triggers run towards the end of the transaction. Subsequent steps include assignment rules, workflow rules, and database commit.
A developer has a Queueable Apex job that needs to query large volumes of data and perform updates. To optimize performance and avoid heap size limits, what is the best practice when querying records inside a Queueable Apex job?
Correct. While Batchable is better for massive datasets, SOQL for-loops are the correct tool within Queueable to manage heap size.
Why this answer
Querying records using a SOQL Query Locator inside a batch or leveraging iterable queries helps manage memory efficiently, but for Queueable jobs, querying using SOQL for loops or batching ids helps avoid heap limits.
An enterprise application requires nightly execution of an Apex class that processes records across multiple objects. Which interface must the Apex class implement?
The Schedulable interface allows classes to be run at scheduled intervals using Cron expressions.
Why this answer
To schedule an Apex job, the class must implement the Schedulable interface, specifically the execute(SchedulableContext sc) method.
A developer needs to write a unit test for a Queueable Apex class. How should the developer verify that the Queueable job executed successfully?
Test.stopTest() forces asynchronous jobs queued inside startTest() to execute before moving to subsequent lines of test code.
Why this answer
Queueable jobs executed inside Test.startTest() and Test.stopTest() run synchronously upon reaching stopTest(), allowing assertions to be checked immediately after.
A developer is writing an Apex trigger and needs to ensure proper bulkification. Which TWO practices should the developer follow to avoid governor limits? (Choose two.)
Correct. Queries and DML inside loops quickly exhaust governor limits.
Why this answer
Bulkification requires processing data in collections (lists/sets) and placing all DML and SOQL operations outside of loops.
A developer is troubleshooting a Batch Apex job that fails intermittently. Which THREE methods or properties are part of the Database.BatchableContext interface available in batch execution? (Choose three.)
Correct. getId() returns the ID of the BatchApexWorker or job.
Why this answer
Database.BatchableContext provides methods to get job IDs and batch IDs during execution.
When comparing Flow Builder decision points and Apex trigger logic, which THREE statements are valid design considerations? (Choose THREE.)
Apex offers advanced programming constructs for complex logic.
Why this answer
Flows are declarative, easier to maintain, and execute within governor limits, whereas Apex handles complex integrations and high-volume data manipulations.
A developer implemented a Queueable Apex class that performs heavy processing. During testing, the developer wants to verify whether the asynchronous job has finished executing before running dependent unit test assertions. What should the developer use?
Test.stopTest() forces asynchronous code to execute synchronously within the test context.
Why this answer
Developers use Test.startTest() and Test.stopTest() in unit tests to force all asynchronous jobs enqueued within the block to execute synchronously before proceeding.
A developer needs to run a batch job that queries records and updates them. What is the default batch size if no optional batch size parameter is specified in Database.executeBatch()?
200 is the default chunk size for batch apex.
Why this answer
The default batch size for Database.executeBatch() is 200 records if not specified.
A developer implements a Queueable class that makes callouts and needs to test it using Test.startTest() and Test.stopTest(). When does the asynchronous queueable job execute during a unit test?
Test.stopTest() forces all asynchronous processes enqueued within the test block to run synchronously.
Why this answer
Asynchronous code executed inside Test.startTest() and Test.stopTest() runs synchronously when Test.stopTest() is called.
A developer creates a Trigger on the Account object that performs a SOQL query inside a for loop. While testing with bulk data operations, the developer encounters a governor limit exception. Which limit is most likely exceeded?
Doing a query per record in a loop violates the 100 SOQL queries per transaction governor limit.
Why this answer
Executing SOQL queries inside a loop without bulkification easily causes the total number of SOQL queries issued per transaction (100) to be exceeded.
A developer has an Apex trigger that fires on Account update. Inside the trigger, it calls a future method to update related Contact records. During testing with 150 Account records modified simultaneously, the developer receives a System.LimitException: Too many future calls. What is the cause of this exception?
Correct. Triggers processing bulk updates can easily exceed the per-transaction limit of 50 future calls.
Why this answer
Future methods cannot be called from within other asynchronous contexts or inside triggers when the trigger processes more records than the future call limit allows per transaction (e.g. max 50 future calls per transaction).
A developer is designing an asynchronous architecture using Batch Apex. Which THREE considerations must be kept in mind regarding Batch Apex behavior? (Choose THREE.)
The concurrent batch execution limit is 5.
Why this answer
Batch apex jobs are queued in the Flex queue, can execute up to 5 concurrent jobs, and can maintain state using Stateful.
Ready to test yourself?
Try a timed practice session using only Process Automation And Logic questions.