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.

21614 already prepared
Salesforce 2026 Release
161 Questions
4.9/5.0

Universal Containers is using a custom Salesforce application to manage customer support cases. The support team needs to collaborate with external partners to resolve certain cases. However, they want to control the visibility and access to the cases shared with the external partners. Which Salesforce feature can help achieve this requirement?

A. Role hierarchy

B. Criteria-based sharing rules

C. Apex managed sharing

D. Sharing sets

C.   Apex managed sharing

Explanation:

To manage customer support cases in a custom Salesforce application where the support team collaborates with external partners while controlling visibility and access, the solution must allow selective sharing with external users (e.g., partners) based on specific conditions. The feature should integrate with Salesforce's security model, support external access (e.g., via Community or Partner portals), and provide granular control over case sharing.

Correct Answer: C. Apex managed sharing
Option C, Apex managed sharing, is the appropriate feature. Apex managed sharing allows developers to programmatically share records, such as cases, with specific users or groups, including external partners, using custom logic. This is ideal for controlling visibility and access based on complex criteria (e.g., case type, priority, or partner role) that standard sharing rules might not handle. By writing Apex triggers or classes, Universal Containers can dynamically grant access to external partners via sharing rules, ensuring security and collaboration. This aligns with the Platform Developer II exam's focus on advanced security customization.

Incorrect Answer:

Option A: Role hierarchy
Option A, Role hierarchy, defines access based on an organization's internal user roles (e.g., managers vs. subordinates) and automatically grants access to records owned by users below in the hierarchy. However, it is designed for internal users and does not natively support sharing with external partners, such as those in a Community or Partner portal. While it can influence visibility, it lacks the flexibility to control access for external collaborators, making it unsuitable for this requirement.

Option B: Criteria-based sharing rules
Option B, Criteria-based sharing rules, allows sharing records with users or groups based on field values (e.g., case status or priority). While useful for internal sharing, it is limited to predefined criteria and does not directly support sharing with external partners unless they are part of a Community with specific profiles or roles. This feature lacks the dynamic, programmatic control needed to manage external partner access on a case-by-case basis, rendering it less effective here.

Option D: Sharing sets
Option D, Sharing sets, are used in Communities to grant access to records (e.g., cases) for Community users based on their profile and a common field (e.g., Account ID). While this can share cases with external partners in a Community, it provides broad access based on predefined rules rather than granular control per case or partner. It is less flexible for managing visibility and access dynamically, making it less suitable than Apex managed sharing for Universal Containers' specific collaboration needs.

Reference:
Salesforce Security and Sharing Guide: "Apex Managed Sharing".

Universal Containers (UC) has enabled the translation workbench and has translated picklist values. UC has a custom multi-select picklist field, Product__c, on the Account object that allows sales reps to specify which of UC’s products an Account already has. A developer is tasked with writing an Apex method that retrieves Account records, including the Product_c field. What should the developer do to ensure the value of Products__c is in the current user's language?

A. Use tolabel ducts__c) in the fields list of the SOQL query.

B. Set the locale on each record in the SOQL result list.

C. Call the translate method on each record in the SOQL result list.

D. Use the Locale clause in the SOQL query.

A.   Use tolabel ducts__c) in the fields list of the SOQL query.

Explanation:

When working with translated picklist values in Salesforce (e.g. using the Translation Workbench), the picklist values stored in the database are stored in English (master value). However, when you want to display these values in the current user's language, you need to retrieve the label version of the field — which includes the translation.

The best practice for retrieving translated values in a SOQL query is to use the toLabel() function. This function returns the user-visible label of a picklist or any other translatable field, based on the user's language settings.

🔍 Option Breakdown:

✅ A. Use toLabel(Products__c) in the fields list of the SOQL query.
➜ Correct approach when querying picklist values that may be translated.
➜ toLabel() ensures the retrieved values reflect the user's current language settings.
➜ Works with single and multi-select picklists.
➜ Syntax example:
SELECT Name, toLabel(Products__c) FROM Account
➜ Best practice for displaying translatable picklist values.

❌ B. Set the locale on each record in the SOQL result list.
➜ The locale affects things like number, date, and time formatting, not picklist translations.
➜ This does not affect picklist label translation.
➜ There is no such method to manually set locale on SOQL result records.

❌ C. Call the translate method on each record in the SOQL result list.
➜ Apex has no built-in translate() method for picklist fields.
➜ Translations are handled at the platform/UI level, not by Apex post-processing.
➜ You must query translated values directly using toLabel().

❌ D. Use the Locale clause in the SOQL query.
➜ SOQL does not support a Locale clause.
➜ Locale is inferred automatically from the current user's language/locale setting.
➜ Invalid syntax – will cause SOQL compilation error.

📚 Reference:
Salesforce SOQL toLabel() function documentation
Translation Workbench Overview – Salesforce Help

A developer has a test class that creates test data before making a mock callout but now receives a 'You have uncommitted work pending. Please commit or rollback before calling out’ error. Which step should be taken to resolve the error?

A. Ensure both the insertion and mock callout occur after the Test.stopTest().

B. Ensure the records are Inserted before the Tezt.startTest() statement and the mock callout occurs within a method annotated with @testSetup.

C. Ensure both the insertion and mock callout occur after the Test.startTest().

D. Ensure the records are inserted before the Test.startTess() statement and the mock callout occurs after the Test. Startest().

C.   Ensure both the insertion and mock callout occur after the Test.startTest().

Explanation:

To resolve the 'You have uncommitted work pending. Please commit or rollback before calling out' error in a test class that creates test data before making a mock callout, the developer needs to understand Salesforce’s transaction management and testing framework. This error occurs because Salesforce does not allow HTTP callouts (even mock callouts) after DML operations (e.g., inserts) within the same transaction unless the transaction is reset or managed properly using Test.startTest() and Test.stopTest(). Let’s evaluate the options based on Salesforce Apex testing best practices.

Key Considerations:
➡️ Salesforce enforces a restriction that prevents callouts after DML operations in the same transaction to avoid governor limit violations and ensure data consistency.
➡️ Test.startTest() resets governor limits and creates a new transaction context, allowing DML and callouts to be separated.
➡️ Test.stopTest() commits the transaction and executes asynchronous code (e.g., callouts), ensuring the mock callout can proceed.
➡️ The test class likely uses Test.setMock() to simulate the callout response.

Evaluation of Options:

A. Ensure both the insertion and mock callout occur after the Test.stopTest().
Test.stopTest() marks the end of the test transaction and commits any DML, executing asynchronous code like callouts. However, performing the insertion and mock callout after Test.stopTest() is invalid because Test.stopTest() concludes the test execution block, and no further code (including DML or callouts) can be executed afterward. This option is incorrect due to improper sequencing.

B. Ensure the records are inserted before the Test.startTest() statement and the mock callout occurs within a method annotated with @testSetup.
The @testSetup method is used to create test data once for all test methods in a class, and DML in @testSetup is committed before test methods run. However, placing the mock callout within @testSetup is problematic because callouts (even mock ones) cannot be performed in @testSetup due to the same uncommitted work restriction, and @testSetup is not designed for callout execution. This option does not resolve the error and is incorrect.

C. Ensure both the insertion and mock callout occur after the Test.startTest().
Test.startTest() resets governor limits and starts a new transaction context. Performing the insertion after Test.startTest() ensures the DML is part of the new transaction. The mock callout can then follow the insertion within this block, as Test.stopTest() (implicitly or explicitly called later) will handle the callout execution. This sequencing avoids the uncommitted work error by ensuring the callout occurs after DML in a controlled transaction, making this a valid approach. However, the exact placement of Test.stopTest() is critical (typically after the callout) to execute it.

D. Ensure the records are inserted before the Test.startTest() statement and the mock callout occurs after the Test.startTest().
Inserting records before Test.startTest() places the DML in the initial transaction, which can lead to the uncommitted work error if a callout follows without a transaction reset. The mock callout after Test.startTest() starts a new context, but the prior DML remains uncommitted, potentially triggering the error unless Test.stopTest() is used to commit the transaction. This option is risky and less reliable than ensuring all DML and callouts occur after Test.startTest() with a proper Test.stopTest().

Correct Answer: C. Ensure both the insertion and mock callout occur after the Test.startTest().
Reason: Placing both the record insertion and mock callout after Test.startTest() ensures they occur within a new transaction context, avoiding the uncommitted work pending error. The developer should follow this with Test.stopTest() to execute the callout and commit the transaction. This approach leverages Salesforce’s testing framework to manage governor limits and callout execution, aligning with the Platform Developer II exam’s “Testing” domain.

Reference: Salesforce Apex Developer Guide - Test.startTest() and Test.stopTest() and Callouts in Tests.

Additional Notes:
The correct implementation would look like this conceptually (without code per your request): set the mock callout using Test.setMock() before Test.startTest(), then after Test.startTest(), insert the records and perform the callout. Call Test.stopTest() afterward to execute the mock response. For example, the test method would structure the DML and callout logic within the Test.startTest() to Test.stopTest() block to ensure proper transaction management.

A developer is debugging an Apex-based order creation process that has a requirement to have three savepoints, SP1, SP2, and 5P3 {created in order), before the final execution of the process. During the final execution process, the developer has a routine to roll back to SP1 for a given condition. Once the condition is fixed, the code then calls 2 roll back to SP3 to continue with final execution. However, when the roll back to SP3 is called, a Funtime error occurs. Why does the developer receive a runtime error?

A. SP3 became invalid when SP1 was rolled back.

B. The developer has too many DML statements between the savepoints.

C. The developer used too many savepoints in one trigger session.

D. The developer should have called SF2 before calling SP3.

A.   SP3 became invalid when SP1 was rolled back.

Explanation:

The issue arises because a runtime error occurs when the developer attempts to roll back to savepoint SP3 after previously rolling back to SP1 during an Apex-based order creation process. The process involves three savepoints—SP1, SP2, and SP3—created in that order, with a rollback to SP1 under a specific condition, followed by an attempt to roll back to SP3 after fixing the condition. Let’s analyze why this error happens based on Salesforce’s savepoint and transaction management rules.

✔ Salesforce allows savepoints to manage transaction boundaries, enabling partial rollbacks within a single transaction.
✔ A savepoint marks a point in the transaction that can be rolled back to, discarding changes made after that point.
✔ When a rollback occurs to an earlier savepoint (e.g., SP1), all savepoints created after it (e.g., SP2, SP3) become invalid because the transaction state reverts to the earlier point.
✔ The runtime error likely stems from attempting to use an invalid savepoint (SP3) after rolling back to SP1.

A. SP3 became invalid when SP1 was rolled back.
This is correct. In Salesforce, when a rollback is performed to an earlier savepoint (e.g., SP1), all subsequent savepoints (SP2 and SP3) are invalidated. Attempting to roll back to SP3 after rolling back to SP1 triggers a runtime error (e.g., System.SavepointException: Savepoint 'SP3' is invalid and cannot be used) because SP3 no longer exists in the transaction context. This explains the developer’s issue.

B. The developer has too many DML statements between the savepoints.
This is incorrect. Salesforce does not impose a specific limit on the number of DML statements between savepoints, only the overall governor limit of 150 DML statements per transaction. The error is tied to savepoint invalidation, not DML count, so this is not the cause.

C. The developer used too many savepoints in one trigger session.
This is incorrect. Salesforce allows up to 35 savepoints per transaction, and three savepoints (SP1, SP2, SP3) are well within this limit. The error is not due to exceeding the savepoint limit but rather the invalidation of SP3 after rolling back to SP1.

D. The developer should have called SP2 before calling SP3.
This is incorrect. The sequence of savepoints (SP1, SP2, SP3) is fixed by their creation order, and rolling back to SP2 before SP3 is not a valid requirement. The problem is that SP3 is invalid after the SP1 rollback, regardless of SP2’s state.

Correct Answer: A. SP3 became invalid when SP1 was rolled back.
Reason: The runtime error occurs because rolling back to SP1 invalidates all later savepoints, including SP3. After the rollback to SP1, the transaction state is reset to that point, and any attempt to roll back to SP3 fails because it no longer exists. To fix this, the developer should avoid rolling back to an earlier savepoint if subsequent rollbacks to later savepoints are needed, or restructure the logic to use a single rollback path (e.g., roll back to SP2 or SP3 directly based on conditions).

Additional Notes: The developer could modify the process to:
✔ Use conditional logic to roll back to the appropriate savepoint (e.g., SP2 or SP3) without reverting to SP1 if SP3 is still needed.
✔ Implement a single transaction flow with nested try-catch blocks to handle errors without invalidating all savepoints.
✔ Test the rollback sequence in a sandbox with debug logs to confirm the transaction state.

A developer is creating a Lightning web component to display a calendar. The component will be used in multiple countries. In some locales, the first day of the week is a Monday, or a Saturday, or a Sunday. ‘What should the developer do to ensure the calendar displays accurately for users in every locale?

A. Query the FirstDayofweek field from the Locale for the current user.

B. Import the @salesforce/i18n module and use the firstdayofweek internationalization property.

C. Use a custom metadata type to store key/value pairs.

D. Use UserInfo.getLocale() in the component.

B.   Import the @salesforce/i18n module and use the firstdayofweek internationalization property.

Explanation:

A developer is building a Lightning Web Component (LWC) that displays a calendar UI. Because the component is used in multiple countries, the first day of the week (Sunday, Monday, or Saturday) must adapt to the user’s locale. The goal is to ensure correct behavior across regions, without hardcoding or manual configuration.

✅ B. Import the @salesforce/i18n module and use the firstDayOfWeek internationalization property
This is the recommended and native approach provided by Salesforce for locale-sensitive values. The @salesforce/i18n module exposes locale-aware values like:
🧩 locale
🧩 timezone
🧩 currency
🧩 decimalSeparator
🧩 firstDayOfWeek
The firstDayOfWeek property automatically reflects the correct day (e.g., 0 for Sunday, 1 for Monday, etc.) based on the current user’s locale (e.g., en_US, fr_FR). This allows the calendar to dynamically adjust without extra configuration or logic.
This method ensures internationalization (i18n) support is consistent and future-proof across components.

❌ A. Query the FirstDayofWeek field from the Locale for the current user
There is no direct field like FirstDayOfWeek exposed in any standard object or the User object. Salesforce does not allow querying locale-specific calendar settings through SOQL or Apex in this way.
Even if locale is stored (e.g., User.LocaleSidKey), it doesn’t provide granular calendar preferences. Attempting to query this is not supported and not possible in Lightning Web Components directly.

❌ C. Use a custom metadata type to store key/value pairs
While custom metadata can be used to define locale-based settings manually (e.g., Locale: en_US → FirstDay: Sunday), this is not scalable and adds manual maintenance.
It lacks the dynamic nature of the @salesforce/i18n module. If a company adds a new locale or if a user changes their locale, the metadata would need to be updated, which introduces risk and technical debt.
This might be viable only in very custom, static cases, but is a poor choice for a dynamic, globally used component.

❌ D. Use UserInfo.getLocale() in the component
The UserInfo.getLocale() method is only available in Apex, not in Lightning Web Components (JavaScript). Therefore, it cannot be used directly inside the LWC controller.
Even if this locale value could be passed from Apex to the component, you would still need extra logic to map it to the correct first day of the week, which is redundant because Salesforce already provides this via @salesforce/i18n.firstDayOfWeek.

✅ Final Answer:
B. Import the @salesforce/i18n module and use the firstDayOfWeek internationalization property
This is the cleanest, most scalable, and Salesforce-recommended way to respect locale-specific calendar settings in Lightning Web Components.

📚 Reference:
LWC Internationalization
@salesforce/i18n module API

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

The Salesforce Platform Developer II certification validates advanced knowledge in Apex, Lightning components, integration patterns, and deployment. It’s designed for developers with hands-on experience building scalable business applications on the Salesforce Platform.
  • Experienced Salesforce developers
  • Technical consultants and architects
  • Professionals aiming to showcase mastery in Apex, Visualforce, Lightning Web Components (LWC), and integrations
You must first hold the Salesforce Platform Developer I certification. Salesforce recommends 2–3 years of development experience on the platform before attempting PDII.
  • 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
Yes. Expect scenario-based questions that test your problem-solving and coding ability, including debugging, refactoring code, and recommending the best architectural approach.
  • 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.
In the exam, pick the method that balances governor limits, scalability, and reliability.
  • 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.