Salesforce-Platform-Developer-II Exam Questions With Explanations

The best unofficial Salesforce-Platform-Developer-II exam questions with research based explanations of each question will help you Prepare & Pass the exam for FREE!

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 2025

Start practicing today and take the fast track to becoming Salesforce Salesforce-Platform-Developer-II certified.

22024 already prepared
Salesforce Spring 25 Release18-Sep-2025
202 Questions
4.9/5.0

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

Given the following containment hierarchy:


What is the correct way to communicate the new value of a property named ‘’passthrough’’ to my-parent-component if the property is defined within my-child-component?

A. Option A

B. Option B

C. Option C

D. Option D

C.   Option C

Explanation:

📘 Explanation:
CustomEvent('passthrough', {...}): creates a custom event named 'passthrough'.
{ detail: this.passthrough }: sends the value of passthrough in the detail payload (required for passing data).
this.dispatchEvent(cEvent): dispatches the event to the DOM so that the parent component can catch it using an event handler like .

❌ Why Other Options Are Incorrect:

A: Incorrect syntax (customEvent should be CustomEvent) — JavaScript is case-sensitive.
B: Doesn't pass any detail, so parent won’t receive the passthrough value.
D: passthrough is passed as a variable without quotes, causing a ReferenceError unless a variable named passthrough exists (but not passing it correctly in detail either).

Reference:
Salesforce Developer Guide - Create and Dispatch Events

A developer built an Aura component for guests to self-register upon arrival at a front desk kiosk. Now the developer needs to create a component for the utility tray to alert users whenever a guest arrives at the front desk. What should be used?

A. DML Operation

B. Changelog

C. Application Event

D. Component Event

C.   Application Event

Explanation:

The developer has built an Aura component for guests to self-register at a front desk kiosk and now needs to create a utility tray component to alert users (e.g., front desk staff) whenever a guest arrives. This requires communication between components, likely across different parts of the application, to notify users of the guest registration event. Let’s evaluate the options:

Option A: DML Operation A Data Manipulation Language (DML) operation (e.g., insert, update) is used to modify data in Salesforce, such as saving a guest’s registration details. While DML might be part of the self-registration process, it is not a mechanism for alerting or notifying users via a utility tray component. This option is incorrect for the purpose of event notification.

Option B: Changelog A changelog typically refers to tracking changes to records (e.g., via Field History Tracking or a custom solution), but it is not designed for real-time notifications or communication between components. It serves as a historical record rather than an active alerting mechanism, making this option unsuitable.

Option C: Application Event In the Aura framework, an application event is used to communicate between components across the entire application, regardless of their position in the component hierarchy. When a guest self-registers, the registration component can fire an application event to signal the arrival. The utility tray component, designed to alert users, can be configured to handle this event and display the alert. This is the appropriate choice for broadcasting the guest arrival notification to all relevant parts of the application, including the utility tray.

Option D: Component Event A component event is used for communication between components that have a parent-child relationship within the same hierarchy. Since the utility tray (likely a global component) and the self-registration component (likely a specific page component) may not be directly related in the component tree, a component event is not suitable. Application events are better suited for cross-application notifications.

Why Option C is Best:
The requirement involves alerting users via a utility tray component whenever a guest arrives, which implies a need for a global notification mechanism. An application event allows the self-registration component to broadcast the guest arrival event, and the utility tray component can listen for and respond to this event by displaying an alert. This aligns with Aura’s event-driven architecture for inter-component communication across the application.

Implementation Notes:
Define an application event (e.g., guestArrivalEvent) in the Aura framework.
Fire the event from the self-registration component when a guest registers.
Register the utility tray component to handle the event and trigger the alert (e.g., show a toast or update the UI).

References:
1. Salesforce Documentation - Application Events in Aura:
Application Events
Explains how application events enable communication across the application.

2. Salesforce Documentation - Component Events in Aura:
Component Events
Contrasts component events with application events, highlighting their use cases.

The Account object has a field, Audit_Code_c, that is used to specify what type of auditing the Account needs and a Lookup to User, zudizar_c, that is the assigned auditor. When an Account is initially created, the user specifies the Audit_Code c. Each User in the org has a unique text field, Audit_Code _e, that is used to automatically assign the correct user to the Account’s Auditor_c field.


What should be changed to most optimize the code’s efficiency?
(Choose 2 answers)

A. Add an initial SOQL query to get all distinct audit codes.

B. Build a Map> of audit code to accounts.

C. Build a Map>of Account Id to audit codes.

D. Add a WHERE clause to the SOQL query to filter on audit codes.

B.   Build a Map> of audit code to accounts.
D.   Add a WHERE clause to the SOQL query to filter on audit codes.

Explanation:

an Apex trigger or process on the Account object that, upon creation, sets the Auditor__c lookup field based on the Audit_Code__c value matching the Audit_Code__c field on a User record. The goal is to optimize efficiency, likely by reducing SOQL queries, minimizing loops, or improving data structure usage, given the involvement of over 10,000 records (as hinted by prior context). The options suggest improvements to SOQL queries and data mapping. Let’s evaluate the options based on best practices for handling large datasets in Apex.

Assumed Scenario:
➡️ A trigger on Account (after insert) queries User records to find a match between Account.Audit_Code__c and User.Audit_Code__c, then updates Account.Auditor__c.
➡️ Without optimization, this might involve multiple SOQL queries (e.g., one per Account) or inefficient loops, hitting governor limits (e.g., 100 SOQL queries, 10,000 DML rows).
➡️ The solution should minimize queries and use efficient data structures (e.g., Maps).

Key Considerations:
✔ Salesforce governor limits: 100 SOQL queries, 10,000 DML rows per transaction.
✔ For 10,000+ Account records, bulkification is critical to avoid query limits.
✔ A Map can store relationships (e.g., Audit_Code__c to User) to reduce query overhead.

Evaluation of Options:

A. Add an initial SOQL query to get all distinct audit codes.
This suggests querying User records to collect unique Audit_Code__c values before processing Account records. However, this alone doesn’t optimize the assignment logic unless followed by a query to map these codes to User records. It reduces redundant queries if audit codes are pre-filtered, but without a subsequent Map or filter, it’s incomplete. This is a partial step but not sufficient on its own.

B. Build a Map of audit code to accounts.
This likely intends Map (typo corrected from “accounts” to “User”), mapping each Audit_Code__c to the corresponding User (based on User.Audit_Code__c). A single SOQL query (e.g., SELECT Id, Audit_Code__c FROM User) can populate this Map, allowing bulk assignment of Auditor__c for all Account records in a loop. This optimizes by reducing queries from N (one per Account) to 1, making it highly efficient for large datasets.

C. Build a Map of Account Id to audit codes.
This creates a Map to store Account IDs and their Audit_Code__c values. While useful for tracking, it doesn’t directly help assign Auditor__c unless combined with a User Map. It might reduce redundant access to Account fields, but the primary bottleneck is the User lookup, not Account data. This is less impactful than mapping Audit_Code__c to User.

D. Add a WHERE clause to the SOQL query to filter on audit codes.
Adding a WHERE clause (e.g., WHERE Audit_Code__c IN :distinctAuditCodes) to the User SOQL query filters records to only those with relevant Audit_Code__c values, reducing the query’s scope. This complements option A or B, minimizing processed records and improving performance, especially with many User records. This is a valuable optimization when paired with a Map.

✅ Correct Answers: B. Build a Map of audit code to accounts and D. Add a WHERE clause to the SOQL query to filter on audit codes.

Reason:
B: Building a Map (corrected from “accounts” to “User”) allows a single SOQL query to fetch all User records and map their Audit_Code__c to Id. In the trigger, loop through Account records, set Auditor__c using the Map (e.g., acc.Auditor__c = userMap.get(acc.Audit_Code__c).Id), and perform a single update. This eliminates N+1 query problems.
D: Adding a WHERE clause (e.g., WHERE Audit_Code__c IN :auditCodeSet) to the User query, where auditCodeSet is derived from Trigger.new Audit_Code__c values, reduces the query size, enhancing efficiency for large orgs with many User records.

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.

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.

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!

Salesforce Platform Developer II Exam – 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. You’ll see questions about debugging, refactoring code, and recommending the best architectural approach.
Yes. Salesforce allows:
  • 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.

Integration is tricky because all options “work.” Quick rules of thumb:
  • 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.
Many developers fail here. Focus on:
  • 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.
Many candidates don’t know what’s next. Post-certification:
  • Update LinkedIn and resume with “Salesforce Platform Developer II Certified” — it’s highly valued by employers.
  • Join Salesforce Developer Community Groups to network.
  • Start contributing to open-source Salesforce projects or blogs — recruiters notice active contributors.