Courseiva

CCNA Process Automation And Logic Questions

28 of 103 questions · Page 2/2 · Process Automation And Logic · Answers revealed

76
MCQhard

When a record-triggered flow performs an action that causes a trigger to fire, which order of execution phase is this?

A.The flow fails
B.The trigger is queued for later
C.The trigger executes immediately in the same transaction
D.The trigger is ignored
AnswerC

Record-triggered flows configured to run before or after save operate within the exact same database transaction as the DML operation that initiated them. When such a flow performs an action that subsequently causes an Apex trigger or another automation to fire, that secondary trigger satisfies the stem's condition by executing immediately within that very same transactional context, rather than being deferred or routed asynchronously.

Why this answer

This is part of the re-entrant execution, where Salesforce processes the trigger as part of the flow's transaction.

77
MCQeasy

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?

A.Trigger.isExecuting
B.Trigger.isBefore
C.Trigger.isInsert
D.Trigger.isUpdate
AnswerD

`Trigger.isUpdate` returns a Boolean value of true specifically when an update DML operation initiates the execution context, allowing developers to cleanly separate update logic from insert logic. This satisfies the stem constraint of determining whether an update operation fired the trigger rather than an insert, directly evaluating the operational event context provided by the platform runtime without requiring manual inspection of record ID fields.

Why this answer

Trigger.isUpdate returns true if the trigger was fired due to an update operation.

78
Multi-Selecthard

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.

Select 3 answers
A.Call Limits.getQueries() at the start of every trigger to abort if limits are near.
B.Utilize Custom Settings or Custom Metadata to provide a global toggle to turn off triggers dynamically.
C.Wrap all DML statements in a try-catch block that catches recursion exceptions.
D.Compare old and new field values using Trigger.oldMap and Trigger.newMap to check if relevant fields actually changed.
E.Use a static boolean variable in a helper class set to false after the first execution.
AnswersB, D, E

Utilising Custom Settings or Custom Metadata enables developers to define a global toggle that can be evaluated at the beginning of an Apex trigger execution context. By checking this configurable boolean flag before running the trigger logic, administrators or developers can dynamically bypass the recursive execution path without needing a code deployment. This satisfies the requirement to safely prevent infinite recursion by providing an externally manageable switch to halt recurring update operations.

Why this answer

Option B is correct because Custom Settings or Custom Metadata can store a global bypass flag that the trigger checks before executing, allowing developers to disable trigger logic dynamically without deploying code changes, which safely breaks recursive update loops. Option D is correct because comparing Trigger.oldMap and Trigger.newMap lets the trigger verify that the fields it cares about actually changed before performing DML, so an update that does not modify relevant fields will not re-fire the same logic and cause infinite recursion. Option E is correct because a static Boolean variable in a helper class persists for the duration of a single transaction, so setting it to false after the first execution prevents the trigger from running its logic again during the same transaction's recursive DML.

Option A is not appropriate because Limits.getQueries() only reports the number of SOQL queries already issued and aborting near governor limits does not logically prevent recursion. Option C is not appropriate because recursion is not an exception that can be caught; wrapping DML in try-catch does not stop the trigger from re-invoking itself.

79
MCQhard

A developer encounters a 'System.AsyncException: Maximum queueable jobs added to the queue' error. What caused this exception?

A.Running more than 500 batch jobs simultaneously.
B.Exceeding the daily asynchronous Apex limit of 250,000.
C.Making more than 100 callouts in a future method.
D.Exceeding the maximum number of 50 queued jobs in a single transaction.
AnswerD

Queuing more than 50 jobs in a single transaction directly triggers this `System.AsyncException` because the asynchronous framework enforces a strict governor limit of 50 `System.enqueueJob` calls per execution context. When a developer attempts to exceed this ceiling—typically through recursive queueable chains or bulk-triggered asynchronous processing—the platform halts execution to protect shared resources. This specific limitation prevents runaway loops from monopolising multi-tenant server capacity, making this option the exact cause of the described error.

Why this answer

Exceeding the limit of 50 queued jobs added to the flex queue in a single transaction triggers this AsyncException.

80
MCQeasy

Which governor limit applies to the total CPU time in a single synchronous Apex transaction?

A.60,000 milliseconds
B.5,000 milliseconds
C.120,000 milliseconds
D.10,000 milliseconds
AnswerD

Synchronous Apex transactions enforce a strict CPU time limit of 10,000 milliseconds to prevent runaway processes from monopolising multitenant server resources. This specific constraint directly addresses the governor limit concerning total CPU time in a single synchronous execution context, distinguishing it from the 60,000-millisecond threshold allocated exclusively to asynchronous transactions.

Why this answer

The synchronous CPU time limit is 10,000 milliseconds (10 seconds).

81
MCQmedium

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?

A.void execute(Database.BatchableContext BC, List<SObject> scope)
B.void finish(Database.BatchableContext BC)
C.Database.QueryLocator start(Database.BatchableContext BC)
D.Database.BatchableContext start(Database.BatchableContext BC)
AnswerC

`Database.QueryLocator` is the correct return type because the scenario requires processing a massive volume of 500,000 Contact records. The `start` method utilising a QueryLocator allows the Apex runtime to bypass standard governor limits by using a lazy-loading cursor that can query up to 50 million records. In contrast, an Iterable or direct `List` return type would restrict the dataset to 50,000 records due to standard SOQL row limits, making the QueryLocator essential for handling large-scale data volumes efficiently in Batch Apex.

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.

82
MCQhard

A developer needs to chain asynchronous jobs. Which interface allows for a single job to be queued from within the execution of another?

A.Queueable
B.Batchable
C.Schedulable
D.Future
AnswerA

`Queueable` implements the `System.Queueable` interface, which satisfies the requirement to chain asynchronous jobs by allowing a job to be queued from within the execution of another using `System.enqueueJob`. Unlike the `@future` annotation, which does not support chaining, `Queueable` returns an `ID` that can be monitored and provides a mechanism to pass complex data types such as sObject records or custom Apex objects, making it the ideal solution for sequential asynchronous processing.

Why this answer

Queueable Apex allows for chaining jobs by calling System.enqueueJob within the execute method.

83
MCQeasy

Which trigger context variable should a developer use to access the map of old record versions prior to the update operation?

A.Trigger.old
B.Trigger.newMap
C.Trigger.oldMap
D.Trigger.new
AnswerC

Trigger.oldMap supplies the pre-update record versions keyed by Salesforce record ID, which is exactly the map of old versions the stem requests. Trigger.old returns only a list, so it cannot provide ID-based lookup during update operations.

Why this answer

Trigger.oldMap provides a map of IDs to the old versions of the SObject records for update and delete triggers.

84
MCQeasy

When should a developer use a record-triggered flow instead of a scheduled path in a flow?

A.When processing millions of historical records nightly.
B.When making external web service callouts synchronously.
C.When actions need to execute 30 days after a contract is signed.
D.When actions need to occur instantly upon record creation.
AnswerD

Record-triggered flows execute synchronously in real time upon record creation or update, which directly satisfies the requirement for instant action specified in the stem. Unlike scheduled paths—which introduce a time delay by queuing actions for execution at a specific date/time or after a set offset—immediate execution bypasses the asynchronous schedule engine entirely. This ensures business logic and database writes occur within the immediate transaction context, preventing latency when immediate data processing is mandated.

Why this answer

Record-triggered flows execute immediately upon record creation or update, whereas scheduled paths run at a specific time offset.

85
MCQmedium

When should a developer choose a Record-Triggered Flow over an Apex trigger for automating record updates before save?

A.When the automation requires complex external web service callouts.
B.When handling recursive trigger execution across multiple custom objects.
C.When performing complex DML operations on up to five related child objects.
D.When updating fields on the same record being saved for better performance and maintainability.
AnswerD

Record-Triggered Flows operating in "Fast Field Updates" (before-save) mode execute within the same transaction without triggering an additional recursive save, satisfying the requirement to update fields on the same record efficiently. This architectural design avoids the overhead of traditional Apex triggers, which require explicit field assignment followed by a separate database operation context, thereby significantly reducing CPU time limits and improving overall maintainability through a declarative interface.

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.

86
MCQeasy

Which trigger event handles the restoration of records from the Recycle Bin?

A.Before Undelete and After Undelete
B.Before Insert and After Insert
C.Before Update
D.Before Delete and After Delete
AnswerA

Apex triggers support `before undelete` and `after undelete` context variables specifically to handle record restoration from the Recycle Bin, satisfying the exact trigger event constraint specified in the stem. Developers can leverage these specific events to execute validation rules, modify field values before the records are fully restored, or perform post-restoration logging and related-record updates. No other trigger events fire during the undelete lifecycle phase, making these the mandatory hooks for intercepting and processing restored data.

Why this answer

Undelete triggers handle records restored from the recycle bin.

87
MCQhard

A developer needs to abort a scheduled Apex job programmatically from within a test class or maintenance script. Which method should be used?

A.System.cancelJob()
B.apexJob.terminate()
C.Database.stopBatch()
D.System.abortJob()
AnswerD

`System.abortJob()` accepts the unique string identifier (`ID`) of a scheduled Apex job and terminates its execution pipeline programmatically. This satisfies the core constraint of the stem—the requirement to abort a scheduled job via code rather than manually through the Salesforce user interface. By passing the `CronTrigger` ID returned upon job scheduling, developers can reliably clean up asynchronous queues during test class execution or maintenance scripts without relying on external administrative intervention.

Why this answer

System.abortJob(jobId) cancels a scheduled or flex-queued asynchronous job.

88
Multi-Selectmedium

Which TWO best practices should developers follow when implementing Queueable Apex chaining? (Choose two.)

Select 2 answers
A.Chain multiple queueable jobs simultaneously within a single synchronous transaction without limits.
B.Use future methods inside queueable execute methods instead of chaining queueable jobs.
C.Ensure that chained jobs handle governor limits and bulk data efficiently in each execution context.
D.Implement exit criteria or conditional checks to prevent infinite job chaining loops.
E.Hardcode all job IDs to ensure static binding between jobs.
AnswersC, D

Queueable Apex chaining initiates a new execution context with every subsequent job, which resets the governor limit counters. However, relying on this reset without designing for efficiency in each context can quickly lead to exhaustion of cumulative limits such as daily asynchronous Apex execution caps or heap size thresholds. By handling bulk data and governor limits properly within every chained link, developers ensure the transaction remains well within Salesforce platform boundaries, satisfying the requirement for robust execution and scalability across multi-step asynchronous processes.

Why this answer

Chaining queueable jobs should be conditional to avoid infinite loops and should monitor flex queue limits.

89
MCQmedium

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?

A.Use an immediate DML statement update Trigger.new; inside the trigger.
B.Instantiate a separate list of the same records and call database.insert().
C.Utilize an after insert trigger to perform an update DML operation.
D.Assign values directly to the fields on the records in Trigger.new.
AnswerD

In a `Before Insert` trigger context, records exist solely in memory and have not yet been committed to the database. Directly assigning values to fields on the records within `Trigger.new` modifies the sObject instances in-flight, which satisfies the stem requirement to update fields on the same record currently being inserted. Because this manipulation occurs prior to the database insertion, no explicit `DML` statement such as `update` is required or even permitted, avoiding recursion and unnecessary governor limit consumption.

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.

90
MCQhard

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?

A.Roll-up summary fields are calculated before before-triggers fire.
B.Roll-up summaries are deferred until a nightly batch runs.
C.Roll-up summary fields on the parent record are calculated after child DML and can trigger parent-level rules and triggers.
D.Roll-up summary calculations never trigger parent triggers.
AnswerC

Roll-up summary fields recalculate on the parent after child DML commits, satisfying the stem's ordering constraint. This recalculation then fires parent-level validation rules and triggers, so the developer must anticipate recursive or duplicate execution. Unlike formula fields, which compute at query time, roll-ups persist and drive automation.

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.

91
MCQhard

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?

A.System.getCPU()
B.AsyncApexJob.getCpuTime()
C.BatchContext.getCpuTime()
D.Limits.getCpuTime()
AnswerD

`Limits.getCpuTime()` dynamically returns the current CPU time consumed in milliseconds within the transaction, satisfying the requirement to monitor and manage the strict CPU time governor limit during heavy batch processing. By calling this method inside the `execute()` method, a developer can programmatically evaluate resource consumption against the platform's synchronous or asynchronous execution thresholds. This enables proactive logic branching, such as deferring remaining work to subsequent iterations or streamlining complex calculations to prevent unhandled `LimitException` faults when processing large volumes of records.

Why this answer

Limits.getLimitCpuTime() and Limits.getCpuTime() allow developers to monitor resource usage dynamically.

92
MCQmedium

A developer is building a solution that requires complex branching logic. When should the developer choose Apex over Flow?

A.When complex procedural logic is needed
B.When updating fields
C.When using standard objects
D.When sending emails
AnswerA

Apex provides object-oriented programming constructs such as loops, switch statements, nested if-else blocks, and custom exception handling, which directly satisfy the requirement for complex procedural logic. While Flow can manage branching pathways through decision elements, deeply nested and intricate algorithmic branching becomes difficult to maintain visually. Procedural code handles complex, multi-variable conditional evaluations more efficiently by executing sequential instructions within a strongly typed environment, making Apex the appropriate choice for sophisticated programmatic workflows.

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.

93
Multi-Selectmedium

Which TWO of the following statements about Trigger.new and Trigger.old are accurate?

Select 2 answers
A.Trigger.old is available in insert triggers
B.Trigger.old is available in update triggers
C.Trigger.newMap is available in before insert
D.Trigger.new is available in delete triggers
E.Trigger.new is available in update triggers
AnswersB, E

`Trigger.old` provides a read-only collection of sObject records representing their state prior to the DML operation, making it accessible exclusively within update and delete contexts. In an update trigger, this context variable is vital because it exposes the pre-values of fields, allowing developers to compare existing database values against the incoming modifications found in `Trigger.new`. Without this contextual availability, implementing validation rules or differential logic based on prior record states would be impossible.

Why this answer

Trigger.new is always present on insert/update; Trigger.old is always present on update/delete.

94
MCQeasy

Which trigger context variable returns a map of IDs to the new versions of the sObject records?

A.Trigger.newMap
B.Trigger.old
C.Trigger.new
D.Trigger.oldMap
AnswerA

Trigger.newMap returns a Map<Id, sObject> keyed by record ID, with values holding the new versions of each sObject in the trigger batch. It satisfies the stem's need to correlate IDs to incoming record state, unlike Trigger.new, which is an unordered list.

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.

95
MCQeasy

Which tool is best for automating a process that requires UI interaction, such as a wizard screen?

A.Future Method
B.Flow Builder
C.Batch Apex
D.Apex Trigger
AnswerB

Screen Flows within Flow Builder provide a reactive user interface via configurable wizard-like screens, successfully satisfying the stem's requirement for direct UI interaction. Unlike backend automation tools that execute entirely without user touchpoints, Flow Builder supports the rendering of step-by-step visual components, input fields, and navigational buttons directly within Lightning pages or experiences, allowing administrators to guide users through complex data-collection processes sequentially.

Why this answer

Flow Builder is the only declarative tool among the options that can present screen elements (wizard-style UI) to users, collecting input across multiple steps and then performing logic or DML. Screen Flows are specifically designed for guided UI interaction, making Flow Builder the correct choice for automating a process that requires a wizard screen.

Exam trap

The trap is conflating 'automation' with 'UI automation'—candidates may pick Batch Apex or Triggers because they automate processes, but only Flow Builder can render interactive screens.

How to eliminate wrong answers

Option A is wrong because a Future method is an asynchronous Apex construct that runs in the background with no UI—it cannot render screens or collect user input. Option C is wrong because Batch Apex processes large data volumes asynchronously in chunks, with no user-facing interface. Option D is wrong because an Apex Trigger fires automatically on DML events (insert/update/delete) and cannot present UI to a user.

96
MCQmedium

A developer needs to write a unit test for a Queueable Apex class. How should the developer verify that the Queueable job executed successfully?

A.Use System.assertAsync() to poll the job status table.
B.Enclose the execution within Test.startTest() and Test.stopTest(), then query for the resulting record changes.
C.Query the AsyncApexJob table without Test.stopTest().
D.Call the queueable execute method directly in a try-catch block.
AnswerB

Test.stopTest() forces all asynchronous jobs queued since Test.startTest() to run synchronously before execution resumes. This satisfies the requirement to verify the Queueable job's outcome, since querying afterwards reliably reflects the record changes the job performed. Without this boundary, the job would remain pending and assertions would fail.

Why this answer

Queueable jobs executed inside Test.startTest() and Test.stopTest() run synchronously upon reaching stopTest(), allowing assertions to be checked immediately after.

97
Multi-Selectmedium

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.)

Select 2 answers
A.Use single record DML statements inside a standard for-loop.
B.Hardcode record IDs to query specific test records.
C.Perform SOQL queries and DML operations outside of loops.
D.Annotate the trigger with @future to ensure asynchronous bulk processing.
E.Use Trigger context variables such as Trigger.new to process collections of records.
AnswersC, E

Executing SOQL queries or DML operations inside loops directly causes a failure to satisfy the critical bulkification requirement, as Salesforce enforces strict governor limits of 100 SOQL queries and 150 DML statements per transaction. By relocating these database interactions outside of code loops and processing records in collections, the developer aggregates the operations into single bulk requests. This architectural pattern drastically reduces the total number of transaction context executions, ensuring the Apex trigger successfully scales to handle multiple records simultaneously without hitting runtime limits.

Why this answer

Bulkification requires processing data in collections (lists/sets) and placing all DML and SOQL operations outside of loops.

98
Multi-Selectmedium

When comparing Flow Builder decision points and Apex trigger logic, which THREE statements are valid design considerations? (Choose THREE.)

Select 3 answers
A.Apex triggers are executed after all Flow Builder automations have completed.
B.Apex triggers provide superior control for complex exception handling and multi-object transaction orchestration.
C.Flow Builder allows administrators to configure logic visually, reducing maintenance overhead for non-developers.
D.Flow Builder cannot invoke Apex actions.
E.Record-Triggered Flows can execute either before or after the record is saved to the database.
AnswersB, C, E

Apex triggers enable developers to implement granular try-catch blocks and custom rollback logic, which are essential for managing complex exception handling across multi-object transactions. Unlike Flow Builder, which operates within a more constrained declarative framework, Apex provides programmatic access to the full transaction lifecycle. This capability satisfies the design requirement for robust orchestration, allowing developers to maintain data integrity and precise control when performing cross-object operations that necessitate sophisticated error management beyond standard declarative capabilities.

Why this answer

Flows are declarative, easier to maintain, and execute within governor limits, whereas Apex handles complex integrations and high-volume data manipulations.

99
MCQmedium

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?

A.Test.startTest() and Test.stopTest() block around the enqueueJob call
B.AsyncApexJob query inside a loop with Thread.sleep()
C.A custom countdown latch pattern using platform cache
D.System.assertAsyncExecution() method
AnswerA

Wrapping the `enqueueJob` call within a `Test.startTest()` and `Test.stopTest()` block forces the asynchronous process to execute synchronously within the test context. Once `Test.stopTest()` is invoked, the platform processes all queued jobs, ensuring they complete before the subsequent lines of code execute. This mechanism satisfies the requirement to verify job completion before running dependent assertions, as it guarantees that the heavy processing finishes and all resulting database changes are committed before the test continues to evaluate the final state.

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.

100
MCQmedium

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()?

A.200
B.50
C.2000
D.500
AnswerA

Database.executeBatch() defaults to 200 records per batch when the optional scope parameter is omitted, satisfying the stem's condition of no specified batch size. This default governs how many records each batch chunk processes before the job commits, directly answering the question's requirement for the standard behaviour.

Why this answer

The default batch size for Database.executeBatch() is 200 records if not specified.

101
MCQhard

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?

A.At the end of the test method automatically without stopTest.
B.Immediately when enqueued.
C.Only when explicitly mocked via HttpCalloutMock.
D.When Test.stopTest() is executed.
AnswerD

Executing `Test.stopTest()` forces the asynchronous queueable job to process immediately within the unit test context. This mechanism satisfies the constraint of testing callouts, which are otherwise prohibited in synchronous Apex code. By wrapping the job execution between `Test.startTest()` and `Test.stopTest()`, the developer ensures the platform processes the queued task before the test assertions are evaluated. This approach allows for the verification of side effects resulting from the callout, providing a reliable method to validate asynchronous logic without relying on external system timing.

Why this answer

Asynchronous code executed inside Test.startTest() and Test.stopTest() runs synchronously when Test.stopTest() is called.

102
MCQhard

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?

A.Maximum CPU time on a Salesforce server (10,000 milliseconds)
B.Total number of SOQL queries issued (100)
C.Total heap size allocated (6 MB)
D.Total number of DML statements issued (150)
AnswerB

A SOQL query inside a for loop executes once per record, so bulk operations quickly exhaust the 100 synchronous query limit. Salesforce counts each loop iteration as a separate query against the governor limit, unlike a single query outside the loop. This directly satisfies the stem's bulk-data constraint.

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.

103
Multi-Selecthard

A developer is designing an asynchronous architecture using Batch Apex. Which THREE considerations must be kept in mind regarding Batch Apex behavior? (Choose THREE.)

Select 3 answers
A.The maximum batch size query locator limit is 200 records maximum.
B.Up to 5 batch jobs can be in execution concurrently for a single organization.
C.Batch Apex automatically executes synchronously if triggered from a Visualforce controller.
D.Batch jobs placed in the queue when the active limit is reached enter the Flex Queue in Holding status.
E.Implementing Database.Stateful ensures member variables retain their values across all transaction chunks.
AnswersB, D, E

Salesforce enforces a strict concurrency limit on asynchronous processing to maintain platform stability and resource availability across multi-tenant environments. Specifically, the organisation-wide governor limit restricts the number of Batch Apex jobs that can run simultaneously to five. This constraint directly addresses the requirement for managing system load when designing asynchronous architectures. Developers must account for this threshold to ensure that queued processes do not exceed the permitted execution capacity, which would otherwise result in jobs being held in a holding status until resources become available.

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.

← PreviousPage 2 of 2 · 103 questions total

Ready to test yourself?

Try a timed practice session using only Process Automation And Logic questions.