Platform Developer II Practice Questions: 20 Scenario Questions (2026)

Header image: Platform Developer II practice questions, bars showing the five exam section weights from 27% down to 15%.

Hey friends,

These 20 Platform Developer II practice questions are original scenario questions weighted like the real exam's five sections, each with the answer and an explanation in a dropdown. I wrote every one from the official exam guide objectives and the Apex and LWC developer guides. None are real exam questions.

The real exam has 60 scored questions in 120 minutes, and the passing score is 70%. So aim for 14 of these 20, then read the explanation for every miss, including lucky guesses.

Split here: Process Automation, Logic, and Integration 27% (5 questions), User Interface 20% (4), Testing, Debugging, and Deployment 20% (4), Performance 18% (4), Advanced Developer Fundamentals 15% (3). For the topic map, see my Platform Developer II study guide.

Process Automation, Logic, and Integration (27%): 5 questions

Question 1. A nightly job must update a field on about 6 million Opportunity records selected by one SOQL filter. Which approach fits?

  • A. A Queueable job that queries all records and updates them
  • B. Batch Apex whose start method returns a Database.QueryLocator
  • C. Batch Apex whose start method returns a List built from several queries
  • D. A future method called from a scheduled class
Show the answer and explanation

Answer: B. A QueryLocator bypasses the total SOQL rows limit and can return up to 50 million records, and each execute chunk gets fresh limits.

A list-based Iterable still hits the SOQL row limit, and a single Queueable or future transaction can't query millions of rows. More in QueryLocator vs Iterable.

Question 2. A batch class must report the total number of records it updated when the job finishes. The developer adds an Integer counter and increments it in execute, but finish always shows 0. What's the fix?

  • A. Make the counter static
  • B. Implement Database.Stateful and keep the counter as an instance variable
  • C. Move the counter into the constructor
  • D. Set the scope to 2,000 so there's only one chunk
Show the answer and explanation

Answer: B. Without Database.Stateful, member variables reset to their initial values for each transaction. With it, instance variables keep their values. Static variables reset either way.

See Database.Stateful.

Question 3. When an Order is activated, Salesforce must notify an ERP that will process it on its own time. The ERP has its own subscriber client. Which solution matches the recommended integration pattern?

  • A. A synchronous Apex callout from an after update trigger
  • B. Publish a platform event from a record-triggered flow and let the ERP subscribe with the Pub/Sub API
  • C. Have the ERP poll Salesforce every minute with SOQL
  • D. Salesforce Connect external objects
Show the answer and explanation

Answer: B. This is Remote Process Invocation, Fire and Forget. Salesforce's integration patterns guide rates flow-driven platform events as Best, with external subscribers on the Pub/Sub API.

Triggers can't make synchronous callouts, and polling wastes API calls. See Salesforce integration patterns.

Question 4. A service method inserts an Invoice and its line items. If any line item fails, nothing should be saved. Which code pattern does that?

  • A. Use Database.insert(lines, false) and ignore errors
  • B. Set a Savepoint, do the DML in try, and in catch call Database.rollback(sp) and rethrow or report
  • C. Insert the lines in a future method
  • D. Insert the invoice in a trigger
Show the answer and explanation

Answer: B. A savepoint plus rollback keeps the transaction all-or-nothing when you're catching exceptions yourself. Partial-success DML does the opposite.

Rethrow or report the error after rolling back, so the caller knows it failed.

Question 5. A developer needs to query fields whose API names are stored in a Custom Metadata Type, so the field list changes without code changes. Which feature should they use?

  • A. Static SOQL with bind variables
  • B. Dynamic SOQL with Database.query or Database.queryWithBinds
  • C. A SOSL FIND query
  • D. A formula field
Show the answer and explanation

Answer: B. When field names are only known at runtime, build the query string and run it with dynamic SOQL. Validate the names (for example against Schema describe results) to avoid SOQL injection.

Bind variables bind values, not field names.

User Interface (20%): 4 questions

Question 6. A child Lightning web component must tell its parent that a row was selected and pass the record Id. What should the child do?

  • A. Call a method on the parent with this.template.host
  • B. Dispatch a CustomEvent with the Id in detail, and the parent handles it with an on-prefixed attribute
  • C. Write the Id to a static Apex variable
  • D. Use a public @api property on the child
Show the answer and explanation

Answer: B. Data flows down through @api properties; events flow up. The child dispatches new CustomEvent('select', { detail: recordId }) and the parent listens with onselect.

@api properties pass data from parent to child, not the other way. Basics in Lightning web components basics.

Question 7. A component calls an Apex method imperatively and the call sometimes fails. What's the best way to show the user a friendly error?

  • A. Let the error go to the browser console
  • B. Catch the error in the JavaScript promise and show it with a toast or an inline message
  • C. Return null from Apex instead
  • D. Wrap the component in an iframe
Show the answer and explanation

Answer: B. Imperative Apex returns a promise. Salesforce's own example wraps the await in try/catch and stores the error on the component, which you then render inline or show as a toast.

Swallowing errors or returning null hides real failures from the user.

Question 8. A Visualforce page needs to refresh only a results table when a filter changes, without reloading the page. What should the developer use?

  • A. Wrap the table in an apex:outputPanel with an id and set reRender to that id on the apex:commandLink or other action component
  • B. A full page redirect
  • C. A JavaScript alert
  • D. A standard controller save action
Show the answer and explanation

Answer: A. Visualforce partial page updates work by giving the area an id (for example an apex:outputPanel) and pointing the action component's reRender attribute at it, per the Visualforce Developer Guide.

The exam guide lists partial page refreshes and asynchronous operations under Visualforce techniques.

Question 9. A component must load a third-party charting library. Where should the library live?

  • A. Hard-coded from a public CDN in the HTML template
  • B. In a static resource, loaded with loadScript from lightning/platformResourceLoader
  • C. Pasted into the component's CSS file
  • D. In a Custom Setting
Show the answer and explanation

Answer: B. Static resources package files with the org, and platformResourceLoader loads them into a Lightning web component.

The exam guide asks for the purpose and benefit of static resources in Visualforce, LWC and Aura.

Testing, Debugging, and Deployment (20%): 4 questions

Question 10. A test must check a batch job's results. The asserts run before the batch finishes and fail. What's the fix?

  • A. Add a loop that waits
  • B. Wrap Database.executeBatch in Test.startTest() and Test.stopTest()
  • C. Use System.scheduleBatch instead
  • D. Mark the test with SeeAllData=true
Show the answer and explanation

Answer: B. When Test.stopTest() runs, async work queued after startTest runs synchronously, so asserts after stopTest see the results.

A test can only run one execute, so insert no more records than the scope. See Batch Apex.

Question 11. A class depends on a pricing service class. The developer wants to unit test the class without running the real pricing logic or deploying fake classes. What should they use?

  • A. Test.setMock with HttpCalloutMock
  • B. The Stub API: implement System.StubProvider and create the stub with Test.createStub()
  • C. SeeAllData=true
  • D. A Custom Setting flag to skip pricing
Show the answer and explanation

Answer: B. The Stub API creates stub objects at runtime as anonymous subclasses, so you can isolate the class under test.

HttpCalloutMock is for HTTP callouts, not for replacing an Apex class dependency.

Question 12. A Lightning web component test sets a property after appendChild and immediately checks the DOM, but the old value still shows. Why?

  • A. Jest can't test properties
  • B. The DOM updates asynchronously, so the test must await a resolved Promise before asserting
  • C. Jest tests need a scratch org
  • D. The property must be static
Show the answer and explanation

Answer: B. LWC re-renders asynchronously. Return or await Promise.resolve() before checking the DOM.

See LWC Jest testing.

Question 13. A team wants every change tracked in version control, validated automatically, and deployed the same way to each environment. Which approach fits source-driven development?

  • A. Change sets built by hand in production
  • B. Salesforce DX projects with the Salesforce CLI in a CI pipeline
  • C. Editing code directly in production through the Developer Console
  • D. Emailing metadata files
Show the answer and explanation

Answer: B. Source-driven development keeps the source of truth in version control and uses the Salesforce CLI to validate and deploy, usually from a pipeline.

Change sets work, but they aren't source-driven and are hard to automate.

Performance (18%): 4 questions

Question 14. A batch QueryLocator includes a relationship subquery for Contacts and runs slowly. What change does Salesforce recommend?

  • A. Increase the scope to 5,000
  • B. Remove the subquery from the QueryLocator and query Contacts inside execute
  • C. Use FOR UPDATE in the start query
  • D. Switch to a future method
Show the answer and explanation

Answer: B. Salesforce says a relationship subquery in the QueryLocator forces a slower, non-chunking implementation. Querying children in execute keeps fast chunking.

The scope max with a QueryLocator is 2,000, and FOR UPDATE isn't applicable in batch start.

Question 15. A Lightning page calls an external service that sometimes takes many seconds to answer, and users hit long-running request limits. What should the developer use?

  • A. A synchronous callout with a longer timeout
  • B. An asynchronous callout (continuation) from the Apex controller
  • C. A future method that returns the value to the component
  • D. A trigger
Show the answer and explanation

Answer: B. Salesforce's integration patterns guide recommends an asynchronous callout, also called a continuation, when the remote endpoint risks high latency.

Future methods can't return values to the UI.

Question 16. This trigger hits the SOQL limit during a data load: for (Contact c : Trigger.new) { Account a = [SELECT Name FROM Account WHERE Id = :c.AccountId]; }. What's the fix?

  • A. Add LIMIT 1 to the query
  • B. Collect AccountIds in a Set, run one query into a Map before the loop, and read from the Map
  • C. Move the code into a future method
  • D. Use SOSL instead
Show the answer and explanation

Answer: B. One query per record means a 200-record chunk burns 200 queries. Bulkify: one query for the whole set, then map lookups.

More patterns in Apex trigger best practices.

Question 17. Three classes each run nearly the same SOQL query on Opportunity with slightly different fields, and bugs keep appearing when one copy changes. What's the best refactor?

  • A. Copy the newest version into all three classes
  • B. Move the query into a Selector class that all three call
  • C. Add the query to a Custom Label
  • D. Use dynamic SOQL in each class
Show the answer and explanation

Answer: B. Trailhead's Apex Enterprise Patterns put queries in a Selector layer so every caller gets the same fields and criteria.

See Apex design patterns.

Advanced Developer Fundamentals (15%): 3 questions

Question 18. On a custom object, each record must be shared with the user in its Reviewer__c lookup, and the access must survive owner changes. What should the developer use?

  • A. Manual sharing with RowCause Manual
  • B. Apex managed sharing with a custom Apex sharing reason
  • C. A criteria-based sharing rule on Reviewer__c
  • D. Make the object Public Read/Write
Show the answer and explanation

Answer: B. Apex managed sharing uses a developer-defined row cause and is kept when the owner changes. Manual shares are removed on owner change, and sharing rules can't target a user from a lookup field.

See Apex managed sharing.

Question 19. An org uses multi-currency. A report-style Apex query must show Opportunity amounts in the running user's currency. What should the query use?

  • A. convertCurrency(Amount) in the SELECT clause
  • B. FORMAT(Amount) only
  • C. A formula field that divides by a hard-coded rate
  • D. toLabel(Amount)
Show the answer and explanation

Answer: A. convertCurrency() converts currency fields to the user's currency in SOQL. FORMAT() applies locale formatting, and toLabel() translates picklist values.

The exam guide calls out localization and multi-currency effects on code.

Question 20. A set of discount thresholds must move from sandbox to production with change sets or packages, along with the app. What should store them?

  • A. Hierarchy Custom Settings
  • B. A Custom Metadata Type
  • C. A custom object
  • D. Hard-coded constants
Show the answer and explanation

Answer: B. Salesforce describes custom metadata as customizable, deployable, packageable and upgradeable, and its records deploy with change sets. Custom settings hold org data, cached for fast access.

Custom Metadata Types also expose getAll() and getInstance() methods in Apex.

How did you do? If you scored under 14, look at which section the misses came from and go back to that part of the study guide.

Cert Lab by Nick Frates

Let the Platform Developer II Cert Lab test you to success

A full bank of Platform Developer II scenario questions across all five sections, with explanations that show why each option fits or doesn't.

Start the Platform Developer II Cert Lab for $9.99 →

Not ready to buy? Try a free lesson and see how fast you learn.

Quick backstory. I loved Focus on Force and used it on my way to 17 Salesforce certifications. At first I read the study guide cover to cover, then took the tests. What I eventually noticed: I learned way faster when I skipped ahead and took practice tests rapid-fire, reading the explanation for every miss. So I built Cert Lab around fast testing, with up-to-date doc links in every explanation. It's designed to test you to success.

FAQ

Are these real Platform Developer II exam questions?

No. I wrote all of them from the exam guide objectives and Salesforce's developer documentation.

How many questions are on the Platform Developer II exam?

60 scored multiple-choice questions plus up to five unscored ones, in 120 minutes.

What score do I need to pass?

70%. See Platform Developer II cost and passing score.

Do I need Platform Developer I first?

Yes. The Salesforce Certified Platform Developer certification is the prerequisite. Compare them in Platform Developer I vs II.

Where should you go next?

Nick Frates, a senior Salesforce developer with 17 certifications, built the Platform Developer II Cert Lab at nickfrates.com: rapid-fire practice questions for every exam section, each answer explained.

Cert Lab by Nick Frates

Let the Platform Developer II Cert Lab test you to success

Lessons, flashcards, a quiz for each of the five exam sections and full practice exams, every answer explained.

Start the Platform Developer II Cert Lab for $9.99 →

Not ready to buy? Try a free lesson and see how fast you learn.

Hope this helps!

Best,

Nick

Keep reading

See all posts →

Salesforce Saturdays

Join 1,033 Salesforce pros getting one 10-minute tip on Salesforce tech or career growth every Saturday.