Free sample lesson from the Platform Developer II Cert Lab. The full course has 22 lessons and 4 full practice exams.
Unlock every section for $9.99PL4: Choosing asynchronous Apex
You’ll be able to: pick future, queueable, batch or scheduled Apex for a requirement and explain the trade-offs.
Which async tool when
| Need | Best fit | Key limit or behavior |
|---|---|---|
| Callout or long work after a trigger, with simple inputs | Queueable (or future) | Future takes primitives only |
| Pass sObjects, get a job ID, or chain jobs | Queueable | 50 enqueueJob calls per sync transaction; 1 child per parent job |
| Process millions of records | Batch Apex | QueryLocator up to 50 million records; limits reset per chunk |
| Run at a set time | Scheduled Apex | Up to 100 scheduled jobs at once |
| Avoid a mixed DML error | Future or queueable | Separates setup and non-setup DML |
Queueable first
Salesforce recommends Queueable Apex instead of future methods. Queueables cover the same use cases and add a job ID from System.enqueueJob (an AsyncApexJob record), non-primitive member variables such as sObjects, and chaining. Future methods take only primitives or collections of primitives, because an sObject could change between the call and the run.
Batch and schedule
Batch Apex runs start, execute and finish. Each execute chunk is its own transaction with fresh limits, and a failed chunk doesn’t roll back earlier ones. Instance variables keep values across chunks only if the class implements Database.Stateful; static variables always reset. Scheduled Apex runs a class on a CRON schedule, ideal for kicking off a nightly batch, and an org can have 100 scheduled jobs at once.
Exam trap
A batch job with scope 200 over 1,000 records is five transactions. If the third fails, the first two stay committed. Design for that partial success.
Predict, then reveal
A trigger must call an external tax service and save the result back to each Opportunity, passing the Opportunity records themselves. Future or queueable?
Show the answer
Queueable with Database.AllowsCallouts: it accepts sObjects and gives you a job ID to monitor.
Try it
- Write a Queueable that updates a field on 5 accounts.
- Enqueue it in anonymous Apex and keep the returned ID.
- Query AsyncApexJob for that ID and watch Status move to Completed.
Practice questions
Ten exam-style questions on this lesson. Answer each one before you open it.
Question 1. Which async option does Salesforce recommend over future methods?
- A. Queueable Apex
- B. Batch Apex
- C. Scheduled Apex
- D. Platform event triggers
Show the answer and explanation
Answer: A. Salesforce recommends Queueable Apex instead of future methods.
Queueables add job IDs, complex types and chaining.
Question 2. Why can’t a future method accept an Account parameter?
- A. Only Strings are allowed
- B. Account records are too large for the async heap limit
- C. Future methods can’t do DML
- D. The record could change before it runs
Show the answer and explanation
Answer: D. sObjects can’t be passed because they may change between the call and the run.
Pass IDs and query inside.
Question 3. What does System.enqueueJob return?
- A. A Boolean
- B. The AsyncApexJob ID
- C. The QueueableContext
- D. Nothing
Show the answer and explanation
Answer: B. enqueueJob returns the ID of the AsyncApexJob record.
Use it to monitor the job.
Question 4. How many child jobs can a queueable job chain from its execute method?
- A. Unlimited
- B. One
- C. Five
- D. Fifty
Show the answer and explanation
Answer: B. Only one child job can exist for each parent job.
Fifty is the enqueue limit for a synchronous transaction.
Question 5. How many queueable jobs can a synchronous transaction add with System.enqueueJob?
- A. 100
- B. 200
- C. 1
- D. 50
Show the answer and explanation
Answer: D. The synchronous limit is 50; the asynchronous limit is 1.
100 is the SOQL limit.
Question 6. A batch job processes 1,000 records with a scope of 200 and the second chunk fails. What happens to the first chunk’s updates?
- A. They’re moved to finish()
- B. They roll back
- C. They stay committed
- D. They’re retried
Show the answer and explanation
Answer: C. Each chunk is its own transaction; earlier successful chunks aren’t rolled back.
Design for partial success.
Question 7. A batch class counts processed records across chunks in an instance variable, but the total is always zero in finish(). What’s missing?
- A. Database.AllowsCallouts
- B. A static variable
- C. Database.Stateful
- D. Schedulable
Show the answer and explanation
Answer: C. Only with Database.Stateful do instance variables keep values between transactions.
Static variables reset between transactions.
Question 8. How many records can a batch start method return with a QueryLocator?
- A. Up to 50 million
- B. Up to 50,000 per transaction
- C. Up to 10,000
- D. Up to 2,000
Show the answer and explanation
Answer: A. A QueryLocator lets batch Apex query up to 50 million records.
50,000 is the normal SOQL row limit.
Question 9. Which statements about scheduled Apex are true? (Choose 2.)
- A. It always runs exactly to the second you specify
- B. An org can have 100 scheduled jobs at once
- C. It can’t start batch jobs
- D. Actual run time can be delayed
Show the answer and explanation
Answer: B, D. There’s a 100-job limit and execution can be delayed by service availability.
It’s ideal for kicking off batch jobs.
Question 10. Which are listed uses for future methods? (Choose 2.)
- A. Callouts to external web services
- B. Chaining jobs with IDs
- C. Avoiding the mixed DML error
- D. Processing 50 million records with a QueryLocator
Show the answer and explanation
Answer: A, C. Future methods suit callouts and separating DML to bypass the mixed save error.
Chaining is queueable; huge volumes are batch.
Before you move on
1. Which keyword locks rows?
Show answer
FOR UPDATE, without ORDER BY.
2. How many fields can GROUP BY ROLLUP take?
Show answer
Up to three.
Key takeaways
- Prefer Queueable over future.
- Future takes primitives only.
- Batch chunks commit independently; use Database.Stateful for totals.
- 100 scheduled jobs at once.
Sources
- Salesforce Developers: Asynchronous Apex
- Salesforce Developers: Future Methods
- Salesforce Developers: Queueable Apex
- Salesforce Developers: Use Batch Apex
- Salesforce Developers: Apex Scheduler
- Salesforce Developers: Execution Governors and Limits
Checked against Salesforce Help, Salesforce Developers docs and Trailhead on Oct 23, 2026. Questions follow the current Platform Developer II exam guide.
Liked this lesson?
There are 21 more like it, plus section checks, flashcards and 4 full 60-question practice exams.
Start studying for $9.99