Salesforce-Platform-Developer-II Exam Questions With Explanations
The best Salesforce-Platform-Developer-II practice exam questions with research based explanations of each question will help you Prepare & Pass the exam!
Over 15K Students have given a five star review to SalesforceKing
Why choose our Practice Test
By familiarizing yourself with the Salesforce-Platform-Developer-II exam format and question types, you can reduce test-day anxiety and improve your overall performance.
Up-to-date Content
Ensure you're studying with the latest exam objectives and content.
Unlimited Retakes
We offer unlimited retakes, ensuring you'll prepare each questions properly.
Realistic Exam Questions
Experience exam-like questions designed to mirror the actual Salesforce-Platform-Developer-II test.
Targeted Learning
Detailed explanations help you understand the reasoning behind correct and incorrect answers.
Increased Confidence
The more you practice, the more confident you will become in your knowledge to pass the exam.
Study whenever you want, from any place in the world.
Salesforce Salesforce-Platform-Developer-II Exam Sample Questions 2026
Start practicing today and take the fast track to becoming Salesforce Salesforce-Platform-Developer-II certified.
22024 already prepared
Salesforce 2026 Release202 Questions
4.9/5.0
Refer to the markup below:
A Lightning web component displays the Account name and two custom fields out of
275 that exist on the abject. The custom fields are correctly declared and
populated. However, the developer receives complaints that the component
performs slowly.
What can the developer do to improve the performance?
A. Replace Layout-type =''Full1" with Layout-type="Partial”.
B. Replace layout-type =''1" with fields=(fields}.
C. Add density="compat" to the component.
D. Add cache="true" to the component.
Explanation:
You are using the
✅ B. Replace layout-type="Full" with fields={fields}
✔️ Best Performance Practice
By using the fields attribute instead of layout-type, you explicitly control which fields to load and render. This reduces payload size, improves load times, and avoids unnecessary processing.
You must pass an array of field API names (like ['Name', 'Custom_Field_1__c', 'Custom_Field_2__c']) using the fields property.
📚 Reference:
lightning-record-form docs
❌ A. Replace layout-type="Full" with layout-type="Partial"
layout-type="Partial" still loads more fields than necessary, typically all fields in the compact layout. It helps slightly more than Full, but still lacks precise control. The performance benefit is minor compared to using fields.
❌ C. Add density="compact" to the component
This only affects the visual layout density (spacing between form elements). It has no impact on performance or how much data is retrieved.
❌ D. Add cache="true" to the component
There is no cache attribute for
✅ Final Answer:
B. Replace layout-type="Full" with fields={fields}
This change ensures the form loads only the necessary fields, improving performance significantly in large-object scenarios.
What should a developer use to query all Account fields for the Acme account in their sandbox?
A. SELECT FIELDS FAOM Account WHERE Name = ‘Acme’ LIMIT 1
B. SELECT FIELDS (ALL) FROM Account WHERE Name = ‘Acme’ LIMIT 1
C. SELECT ALL FROM Account WHERE Name = "Acme’ LIMIT 1
D. SELECT * FROM Recount WHERE Names = ‘Aeme’ LIMIT 1
✅ Explanation:
In Salesforce, SOQL (Salesforce Object Query Language) is used to query data. The goal is to retrieve all fields for an Account record where the Name is 'Acme' and limit the result to one record (assuming 'Acme' is unique). Let’s analyze the options:
Option A:
Issue: SELECT FIELDS is not valid SOQL syntax. The correct syntax to retrieve all fields is SELECT FIELDS(ALL) or SELECT FIELDS(STANDARD)/FIELDS(CUSTOM), but the keyword must be followed by a specifier in parentheses.
Result: This query will fail to execute.
Option B:
Correctness: This uses the valid SOQL syntax FIELDS(ALL), which retrieves all fields (standard, custom, and system fields) for the Account object.
Consideration: FIELDS(ALL) includes all fields, even those that might not be accessible or relevant, but it is a valid approach for querying all fields.
Result: This is a correct and efficient way to query all Account fields for the 'Acme' account, limited to one record.
Option C:
Issue: SELECT ALL is not valid SOQL syntax. The correct syntax for selecting all fields is FIELDS(ALL) or explicitly listing fields. Additionally, the quotation marks are mismatched ("Acme’ should be 'Acme' or "Acme" consistently).
Result: This query will fail due to invalid syntax.
Option D:
Issue:
SELECT * is not valid SOQL syntax; Salesforce does not support the asterisk (*) wildcard like SQL.
Recount seems to be a typo and should be Account.
Names should be Name (case-sensitive field name mismatch).
Aeme appears to be a typo for Acme.
Result: This query will fail due to multiple syntax errors.
Correct Answer:
Option B: SELECT FIELDS (ALL) FROM Account WHERE Name = ‘Acme’ LIMIT 1
Why Option B is Best:
It uses the correct SOQL syntax FIELDS(ALL) to retrieve all fields (standard, custom, and system) for the Account object.
The WHERE Name = ‘Acme’ clause filters for the 'Acme' account.
The LIMIT 1 ensures only one record is returned, which is appropriate if 'Acme' is expected to be unique.
This approach is efficient and aligns with Salesforce’s query capabilities for retrieving all fields dynamically.
Additional Notes:
In a production environment, ensure the developer has access to all fields (e.g., via field-level security).
For better performance and maintainability, explicitly listing required fields is often recommended over FIELDS(ALL) unless all fields are truly needed, but for this specific requirement (querying all fields), Option B is appropriate.
Reference:
Salesforce SOQL and SOSL Reference: FIELDS() Syntax
Trailhead Module: Data Modeling
A developer used custom settings to store some configuration data that changes occasionally. However, tests are now Failing in some of the sandboxes that were recently refreshed. What should be done to eliminate this issue going forward?
A. Set the setting type on the custom setting to List.
B. Replace custom settings with static resources.
C. Set the setting type on the custom setting to Hierarchy.
D. Replace custom settings with custom metadata.
Explanation:
To address the issue where tests are failing in some sandboxes recently refreshed due to the use of custom settings to store configuration data that changes occasionally, the developer needs to identify the root cause and implement a solution to prevent future failures. The problem likely stems from the behavior of custom settings during sandbox refreshes and their impact on test execution. Let’s evaluate the options based on Salesforce data management and testing best practices.
Key Considerations:
✔ Custom settings store configuration data and are available in two types: List (org-wide, like custom objects) and Hierarchy (user- or profile-specific, with data tied to the org’s hierarchy).
✔ During a sandbox refresh, custom setting data is copied from the production org, but the data may not match the sandbox’s configuration or test environment, causing tests to fail if they rely on specific values.
✔ Tests in Salesforce run in an isolated context and do not see org data (including custom settings) unless explicitly created or mocked during the test.
Evaluation of Options:
A. Set the setting type on the custom setting to List.
A List custom setting stores data as records, similar to a custom object, and is org-wide. Changing to List does not inherently resolve the issue, as the data is still copied during a sandbox refresh and may not align with test expectations. Tests would need to create their own List custom setting records, but this does not eliminate the underlying problem of data inconsistency post-refresh. This option is insufficient.
B. Replace custom settings with static resources.
Static resources are immutable files (e.g., JSON, CSV) uploaded to Salesforce, which are not copied or modified during sandbox refreshes. Tests can load specific versions of static resource data using StaticResourceCalloutMock or direct access, ensuring consistency across environments. However, static resources are less flexible for dynamic updates (e.g., occasional changes require re-uploading), and accessing data (e.g., parsing JSON) requires additional code, making this a less ideal replacement for configuration data managed via custom settings.
C. Set the setting type on the custom setting to Hierarchy.
A Hierarchy custom setting allows data to be defined at different levels (org, profile, user), but the issue is not related to the type of custom setting (List vs. Hierarchy). The failure likely occurs because tests rely on custom setting data that varies post-refresh. Changing to Hierarchy does not address the root cause, as the data still depends on the org’s configuration and may not be consistent in sandboxes. This option is incorrect.
D. Replace custom settings with custom metadata.
Custom metadata records are metadata, not data, and are copied consistently across sandbox refreshes, matching the production configuration. Tests can create or query custom metadata records using Test.loadData() or direct SOQL, ensuring predictable behavior. Unlike custom settings, custom metadata is deployable and immutable during test execution, eliminating failures due to sandbox data mismatches. This is the recommended approach for configuration data that changes occasionally.
Correct Answer: D. Replace custom settings with custom metadata.
Reason: Replacing custom settings with custom metadata eliminates the issue by ensuring configuration data is treated as metadata, which is consistent across sandbox refreshes and testable in isolation. This prevents test failures caused by varying custom setting data post-refresh, aligning with the Salesforce Platform Developer II exam’s “Data Modeling and Management” and “Testing” domains.
Reference: Salesforce Developer Guide - Custom Metadata Types and Custom Settings.
Additional Notes:
To implement, create a custom metadata type (e.g., Configuration__mdt) with fields for the configuration data, migrate existing custom setting values, and update Apex to query SELECT DeveloperName, Field__c FROM Configuration__mdt. In tests, use Test.loadData(Configuration__mdt.sobjectType, 'ConfigurationTestData'); to load test-specific records. This ensures stability across environments and simplifies deployment.
How should a developer assert that a trigger with an asynchronous process has successfully run?
A. Create all test data in the test class, use system. runs {} to invoke the trigger, then perform assertions.
B. Insert records into Salesforce, use seeAllData=true, then perform assertions.
C. Create all test data, use future in the rest class, then perform assertions.
D. Create all test data in the test class, invoke Test.startTest{} and Test.etopTaat {} and then perform assertions.
Explanation:
When testing triggers that initiate asynchronous processes (such as @future, Queueable, Batchable, or Schedulable), it's crucial to structure your test method correctly to ensure the asynchronous logic is executed and can be verified through assertions. Simply creating data and calling the trigger is not enough because asynchronous operations run in a separate thread and may not complete during the regular test method execution. Salesforce provides the Test.startTest() and Test.stopTest() methods to specifically handle this issue by flushing and executing asynchronous code queued during testing.
✅ Correct Answer: D. Create all test data in the test class, invoke Test.startTest() and Test.stopTest(), and then perform assertions.
This is the best practice and correct approach when dealing with triggers that result in asynchronous operations. First, you create all required test data and perform operations that fire the trigger. Then, you enclose the operation within Test.startTest() and Test.stopTest() to ensure that asynchronous jobs (e.g., @future or Queueable) are executed within the test context. After Test.stopTest(), assertions are placed to confirm the expected results, ensuring the asynchronous logic was processed properly.
❌ Option A: Create all test data in the test class, use system.runAs{} to invoke the trigger, then perform assertions.
While System.runAs() allows simulation of different user profiles or roles, it does not help manage asynchronous processing. This method is not designed to flush or execute queued asynchronous operations, so using it in this context won’t ensure that the trigger’s asynchronous behavior has completed before assertions are evaluated.
❌ Option B: Insert records into Salesforce, use seeAllData=true, then perform assertions.
This approach is discouraged and incorrect. Using seeAllData=true compromises test isolation and data integrity, relying on actual org data which is not guaranteed to be present or consistent. Moreover, this method doesn’t ensure that asynchronous code has finished executing, which is essential for accurate assertions.
❌ Option C: Create all test data, use future in the test class, then perform assertions.
This option is misleading and vague. You do not "use future" in the test class itself — you write code that triggers future methods. But unless you wrap that in Test.startTest() and Test.stopTest(), those asynchronous methods may not be executed during testing, making the assertions invalid. So, this option fails to correctly describe the mechanism needed for asynchronous verification.
📚 Reference:
Salesforce Developer Guide – Test.startTest() and Test.stopTest()
Salesforce Trailhead – Asynchronous Apex
Best Practices for Testing Asynchronous Code
What are three reasons that a developer should write Jest tests for Lightning web
components?
(Choose 3 answers)
A. To test a component's non-public properties.
B. To test basic user interaction
C. To verify the DOM output of a component
D. To test how multiple components work together
E. To verify that events fire when expected
C. To verify the DOM output of a component
E. To verify that events fire when expected
Explanation:
Writing Jest tests for Lightning Web Components (LWCs) is a critical practice in Salesforce development to ensure code quality, functionality, and reliability. Jest, a JavaScript testing framework, is integrated into the Salesforce LWC development environment to facilitate unit testing. The goal is to validate component behavior, interactions, and output while adhering to best practices. Let's evaluate each option to identify the three most valid reasons for writing Jest tests for LWCs.
Correct Answer:
B. To test basic user interaction
Testing basic user interaction with Jest ensures that a Lightning Web Component responds correctly to user actions such as clicks, inputs, or form submissions. By simulating these interactions (e.g., using fireEvent or triggerEvent), developers can verify that the component's logic executes as intended. This is crucial for user-facing components, as it confirms the UI behaves predictably, enhancing user experience. For the Platform Developer II exam, understanding how to test interactivity is key, making this a primary reason to use Jest in LWC development.
C. To verify the DOM output of a component
Verifying the DOM output of a component with Jest allows developers to ensure the rendered HTML matches the expected structure and content. Using tools like @salesforce/sfdx-lwc-jest and utilities such as createElement, developers can render components and assert against the DOM using query selectors. This is essential for validating visual elements, accessibility, and layout, which are critical for LWC reliability. This testing approach aligns with Salesforce best practices and is a fundamental reason to write Jest tests for LWCs.
E. To verify that events fire when expected
Verifying that events fire when expected is a vital reason to write Jest tests, as LWCs often rely on custom events for communication between components. By testing event emission and handling (e.g., using dispatchEvent and event listeners), developers can ensure the component's event-driven logic works correctly. This is particularly important in complex applications where event propagation impacts functionality. For the Platform Developer II exam, mastering event testing with Jest is a key skill, making it a significant justification for testing.
Incorrect Answer:
Option A: To test a component's non-public properties
Testing a component's non-public properties (e.g., private fields or methods) is generally not a recommended reason to write Jest tests for LWCs. Salesforce encourages testing public APIs and observable behavior rather than internal implementation details, as non-public properties can change without notice. Jest tests should focus on the component's external interface and functionality, not its private state. While technically possible, this approach violates encapsulation principles and is not a primary goal, making it less relevant for the Platform Developer II exam context.
Option D: To test how multiple components work together
Testing how multiple components work together is more suited to integration testing rather than unit testing with Jest. Jest is designed for unit testing individual LWCs in isolation, using mocks or stubs for dependencies. Testing component interactions typically requires a higher-level testing framework or manual testing in a sandbox, as Jest lacks built-in support for end-to-end scenarios. While important, this is outside the scope of Jest's primary purpose for LWCs, making it an incorrect focus for this question.
Reference:
Test Lightning Web Components
Prep Smart, Pass Easy Your Success Starts Here!
Transform Your Test Prep with Realistic Salesforce-Platform-Developer-II Exam Questions That Build Confidence and Drive Success!
Frequently Asked Questions
- Experienced Salesforce developers
- Technical consultants and architects
- Professionals aiming to showcase mastery in Apex, Visualforce, Lightning Web Components (LWC), and integrations
- Questions: 60 multiple-choice/multiple-select
- Time: 120 minutes
- Passing Score: ~70%
- Cost: USD $200 (plus taxes)
- Delivery: Online proctored or Pearson VUE test center
- Advanced Apex programming (asynchronous operations, exception handling)
- Security & sharing model considerations
- Integration techniques (REST, SOAP, external services)
- Testing & debugging
- Deployment & packaging best practices
- Retake after 1 day for the first attempt
- Retake after 14 days for further attempts
- Maximum of 3 attempts per release cycle
- Platform Developer I (PDI): Focuses on core Apex, SOQL, and declarative development.
- Platform Developer II (PDII): Tests advanced coding, performance, architecture, and integration skills.
- REST: Lightweight, modern, mobile/web integrations.
- SOAP: Legacy or when strict contract/WSDL is required.
- Platform Events: Real-time, event-driven architecture.
- Change Data Capture (CDC): Sync Salesforce data with external systems automatically.
- Writing test classes with >75% coverage that assert actual outcomes.
- Using dependency injection, stubs, and mocks for isolation.
- Knowing when to use Unlocked Packages, Change Sets, or SFDX CLI.
- In practice exams, review every “deployment” question twice — they’re often scenario-based and easy to misread.
- Update LinkedIn and resume with “Salesforce Platform Developer II Certified” — highly valued by employers.
- Join Salesforce Developer Community Groups to network.
- Contribute to open-source Salesforce projects or blogs — recruiters notice active contributors.