OpenExamsFREE PRACTICE — ANY EXAM

Free Salesforce Certified Platform Developer II Exam Practice Questions

100 free questions · Answer explanations · No signup required

View examination details, outline and sources

Loading selected examination banks…

Sample Practice Questions

Try these 10 sample questions from the Salesforce Certified Platform Developer II Exam practice bank. Each includes the answer and explanation. Continue with the interactive practice above to review the full question set.

  1. 1A developer uses Collator to sort names for display. Why should the same locale-sensitive ordering be avoided in trigger logic that requires one consistent sort order for every user?

    1. A. It always uses the org's default locale instead of the user's locale.
    2. B. It uses the running user's locale, so results can differ.
    3. C. It uses a fixed Unicode code-point order regardless of the user's locale.
    4. D. It compares only string lengths rather than locale-sensitive collation.

    Answer: B

    Explanation: The guide states, "Because locale-sensitive sorting can produce different results depending on the user running the code, avoid using it in triggers or in code that expects a particular sort order." User-dependent collation conflicts with the trigger’s required consistent ordering.

    Reference: Apex Developer Guide — Lists of Custom Types and Sorting

  2. 2A before-save record-triggered flow sets Region__c on an Account. A before update Apex trigger reads Region__c during the same save. Assuming neither automation changes the field again, which value does the trigger receive?

    1. A. The value before the flow, because Apex always runs first.
    2. B. A null value, because flows cannot pass field changes to triggers.
    3. C. The value from a later transaction after the current save commits.
    4. D. The value set by the flow, because that flow runs before the trigger.

    Answer: D

    Explanation: The order lists "Executes record-triggered flows that are configured to run before the record is saved." immediately before "Executes all before triggers." Thus the before trigger sees the flow’s field assignment in this save.

    Reference: Apex Developer Guide — Triggers and Order of Execution, p. 246, steps 3–4

  3. 3An LWC imports AccountService.load. The Apex declaration is @AuraEnabled public List<Account> load() { return [SELECT Id FROM Account]; }. Which change is required to expose this method for the component call?

    1. A. Change public to private and keep an instance method.
    2. B. Replace @AuraEnabled with the @InvocableMethod annotation.
    3. C. Add static while retaining public and @AuraEnabled.
    4. D. Remove @AuraEnabled and retain the public instance method.

    Answer: C

    Explanation: The documentation states, "To expose an Apex method to a Lightning web component, the method must be static and either global or public." The annotation is also required. The snippet is public and annotated, but lacks static; the other changes do not meet the exposure contract.

    Reference: Expose Apex Methods to Lightning Web Components — Method exposure requirements

  4. 4An Apex unit test must verify behavior for an HTTP 503 response without contacting the external endpoint. The developer needs to generate the response programmatically. Which test setup supplies it?

    1. A. Enable SeeAllData=true and call the live endpoint.
    2. B. Add the endpoint to Remote Site Settings and omit a mock.
    3. C. Register an HttpCalloutMock implementation using Test.setMock().
    4. D. Implement WebServiceMock for the Http.send() request.

    Answer: C

    Explanation: The guide states, "Provide an implementation for the HttpCalloutMock interface to specify the response sent in the respond method". Registering that implementation with Test.setMock supplies the HTTP status and body without a real callout. SeeAllData and remote-site permission do not mock a response, and WebServiceMock targets SOAP-generated calls.

    Reference: Apex Developer Guide — Testing HTTP Callouts by Implementing the HttpCalloutMock Interface

  5. 5A Visualforce controller stores a large derived list needed only during the current request. It can reconstruct the list on a later request and must avoid serializing it into view state. Which declaration change fits this requirement?

    1. A. Declare the instance list global instead of public.
    2. B. Declare the instance list transient.
    3. C. Declare the instance list with @AuraEnabled.
    4. D. Declare a public getter for the same non-transient list.

    Answer: B

    Explanation: The guide states, "Declaring variables as transient reduces view state size." Transient instance variables are excluded from the page’s persisted view state, fitting data needed only for the current request. Visibility, Aura exposure, and getter access do not exclude ordinary instance data from serialization.

    Reference: Visualforce Developer Guide — Using the transient Keyword, p. 124

  6. 6Apex code must read the value of an existing custom label named Payment_Error. Which expression accesses that label?

    1. A. System.Label.Payment_Error
    2. B. Schema.Label.Payment_Error
    3. C. Payment_Error__c.getInstance()
    4. D. UserInfo.getLocale().Payment_Error

    Answer: A

    Explanation: The guide states, "You can only access the value of a custom label using system.label.label_name." Thus System.Label.Payment_Error reads the label; the other expressions confuse labels with schema metadata, custom settings, or user locale information.

    Reference: Apex Developer Guide — Custom Labels, p. 124

  7. 7A user changes a number field from 2 to 8. A workflow field update changes it to 9, causing the update trigger to run again. In that second invocation, what value does Trigger.old contain for the field?

    1. A. 8, the value immediately before the workflow update
    2. B. 2, the value before the initial record update
    3. C. 9, the value assigned by the workflow field update
    4. D. Null, because Trigger.old is unavailable on re-entry

    Answer: B

    Explanation: The guide states, "Instead, Trigger.old holds the object before the initial record update was made." The second invocation therefore compares against 2, not the intermediate value 8 or final value 9.

    Reference: Apex Developer Guide — Triggers and Order of Execution: Additional Considerations, p. 247

  8. 8An LWC uses @wire(loadAccounts) with an Apex method declared @AuraEnabled public static List<Account> loadAccounts(). The method only queries data. Which change satisfies the wire service's Apex annotation requirement?

    1. A. Use @AuraEnabled(cacheable=true) on loadAccounts().
    2. B. Use @future(callout=true) on loadAccounts().
    3. C. Change the method from static to an instance method.
    4. D. Replace @AuraEnabled with the @HttpGet annotation.

    Answer: A

    Explanation: The documentation states, "To use @wire to call an Apex method, annotate the Apex method with @AuraEnabled(cacheable=true)." The read-only method can meet that requirement by adding cacheable=true; the other changes do not make it wire-compatible.

    Reference: Wire Apex Methods to Lightning Web Components — Apex method annotation requirements

  9. 9A service calls a SOAP client class generated from a WSDL. Its generated methods use WebServiceCallout.invoke(). Which testing interface should provide the fake SOAP response?

    1. A. WebServiceMock, implementing doInvoke()
    2. B. HttpCalloutMock, implementing respond()
    3. C. System.StubProvider, replacing WebServiceCallout itself
    4. D. StaticResourceCalloutMock, configured with a response body

    Answer: A

    Explanation: The guide states, "First, implement the WebServiceMock interface and specify the fake response in the doInvoke method." That is the hook for WSDL-generated WebServiceCallout.invoke calls. HttpCalloutMock and StaticResourceCalloutMock provide HTTP-callout responses, while the Stub API cannot replace the WebServiceCallout system type.

    Reference: Apex Developer Guide — Testing Web Service Callouts, p. 548

  10. 10A Visualforce page renders thousands of editable grid cells and responds slowly. Users only need to review a small subset at a time. Which change directly reduces the number of input components processed and transmitted for each page view?

    1. A. Create all rows, then hide nonvisible rows with CSS.
    2. B. Keep all rows bound and rerender the full table with Ajax.
    3. C. Mark the controller's list transient while rendering every row.
    4. D. Use filters and pagination to display only the needed subset.

    Answer: D

    Explanation: The guide explains, "Large data grids result in a Visualforce component tree that processes slowly." Filters and pagination reduce the rows and input components created for each view. CSS hiding and rerendering leave the full tree in place; excluding a backing variable from view state does not reduce the number of rendered input components.

    Reference: Visualforce Developer Guide — Optimize Lists and Tables: Avoid Data Grids if Possible, p. 391

Topics in this practice bank

These topics describe the available practice for Salesforce Certified Platform Developer II Exam. Review the examination outline and its sources for scope and allocation details.

  • Advanced Developer Fundamentals
    • Localization and multi-currency
    • Sharing objects and Apex managed sharing
    • Custom metadata and custom settings
  • Process Automation, Logic, and Integration
    • Declarative and programmatic process interactions
    • Optimal programmatic or declarative solutions
    • Apex trigger best practices
    • Error handling and transactional integrity
    • Advanced SOQL keywords
    • Asynchronous Apex
    • Dynamic Apex
    • Platform event publish / subscribe logic
    • Inbound and outbound programmatic integration
  • User Interface
    • LWC or Aura Component and Apex controller code analysis
    • Visualforce actions, partial refreshes, and asynchronous operations
    • Displaying errors
    • LWC, Aura Component, or Visualforce solution selection
    • Responsive markup and form factor
    • LWC and Aura event communication
    • Static resources
  • Testing, Debugging, and Deployment
    • Advanced Apex testing, mocks and stubs
    • Testing and debugging components, controllers, extensions, and JavaScript
    • Diagnosing unexpected Apex code, trigger, or test execution
    • Source-driven development and deployment
  • Performance
    • User interface performance
    • Logic, query structure, and large data volumes
    • Asynchronous callout performance
    • Code reuse
    • Identifying and resolving code inefficiencies

How to use these free practice questions

Choose an answer, check the explanation, and review your progress by chapter. Practice questions and explanations are free to access without signing up.

These are independent study questions, not actual examination items. For examination requirements and official information, view Salesforce Certified Platform Developer II Exam details.