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 2025
Start practicing today and take the fast track to becoming Salesforce Salesforce-Platform-Developer-II certified.
22024 already prepared
Salesforce Spring 25 Release202 Questions
4.9/5.0
In an organization that has multi-currency enabled, a developer Is tasked with building a Lighting component that displays the top ten Opportunities most recently accessed by the logged in user. The developer must ensure the Amount and LastModifiedDate field values are displayed according to the user's locale. What is the most effective approach to ensure values displayed respect the user's locale settings?
A. Use REGEX expressions to format the values retrieved via SOQL.
B. Use a wrapper class to format the values retrieved via SOQL.
C. Use the FOR VIEW clause in the SOQL query.
D. Use the FORMAT () function in the SOQL query.
✅ Explanation:
In Salesforce, when multi-currency is enabled, field values like Amount are stored in the corporate currency and need to be converted to the user’s currency based on their locale and preferences. Similarly, LastModifiedDate should be displayed in the user’s local date-time format. The Lightning component will render these values, so the solution must ensure proper formatting without manual intervention.
Option A: Use REGEX expressions to format the values retrieved via SOQL
➝ Issue: Regular expressions (REGEX) are not suitable for formatting currency or date-time values dynamically based on locale. They are designed for pattern matching and text manipulation, not for handling Salesforce-specific locale-aware formatting or currency conversion.
➝ Result: Ineffective and error-prone; does not address multi-currency or locale settings.
Option B: Use a wrapper class to format the values retrieved via SOQL
➝ Approach: A wrapper class can encapsulate Opportunity data and use Apex methods like Currency.convertFrom() or DateTime.format() to convert and format Amount and LastModifiedDate according to the user’s locale and currency settings (e.g., via UserInfo.getDefaultCurrency() and UserInfo.getLocale()).
➝ Pros: Provides flexibility to handle formatting logic in Apex, ensuring values are converted and formatted before being passed to the Lightning component. This is a common best practice for complex UI requirements.
➝ Cons: Requires additional code to implement the wrapper and formatting logic, but this is manageable and reusable.
➝ Result: Effective and aligns with Salesforce development practices.
Option C: Use the FOR VIEW clause in the SOQL query
➝ Issue: The FOR VIEW clause is not a valid SOQL syntax. It might be a confusion with FOR UPDATE or other clauses, but no such clause exists for locale-specific formatting or currency conversion in SOQL.
➝ Result: Invalid approach; the query will fail.
Option D: Use the FORMAT() function in the SOQL query
➝ Approach: The FORMAT() function in SOQL can format date-time and currency fields according to the user’s locale. For example, FORMAT(LastModifiedDate) and FORMAT(Amount) will return values in the user’s preferred format and currency.
➝ Pros: Simplifies the solution by handling formatting at the query level, reducing the need for additional Apex logic.
➝ Cons: Limited to the fields supported by FORMAT() (e.g., date, date-time, and currency fields), and the formatting is applied at query time, which might not be as flexible as Apex-based formatting for complex scenarios.
➝ Result: Effective for this specific use case, as Amount and LastModifiedDate are supported fields.
Correct Answer:
Option D: Use the FORMAT() function in the SOQL query.
Why Option D is Best:
➝ The FORMAT() function is designed to handle locale-specific formatting for fields like Amount (converting to the user’s currency) and LastModifiedDate (displaying in the user’s date-time format) directly in the SOQL query.
➝ This approach minimizes Apex code, reducing maintenance overhead and ensuring the Lightning component receives pre-formatted data ready for display.
➝ For the query, it would look like:
SELECT Id, FORMAT(Amount), FORMAT(LastModifiedDate)
FROM Opportunity
WHERE LastViewedDate != null
ORDER BY LastViewedDate DESC
LIMIT 10
➝ This leverages Salesforce’s built-in capabilities, aligning with best practices for efficiency and simplicity.
Additional Considerations:
➝ Ensure the query includes a WHERE clause to filter by the logged-in user’s recently accessed records (e.g., using LastViewedDate with the user’s context).
➝ If more complex formatting or additional logic is needed, Option B (wrapper class) could be a fallback, but for this scenario, FORMAT() suffices.
Reference:
Salesforce SOQL and SOSL Reference: FORMAT() Function
Trailhead Module: Apex Basics & Database
As part of point-to-point integration, a developer must call an external web service which,
due to high demand, takes a long time to provide a response. As part of the request, the
developer must collect key Inputs from the end user before making the callout. Which two
elements should the developer use to Implement these business requirements?
(Choose 2 answers)
A. Lightning web component
B. Apex method that returns a Continuation object
C. Screen Flow
D. Process Builder
B. Apex method that returns a Continuation object
Explanation:
To implement a point-to-point integration where a developer must call an external web service that takes a long time to respond, while collecting key inputs from the end user before making the callout, the solution must handle both user interaction and the asynchronous nature of the long-running callout. The approach should align with Salesforce’s capabilities for user interface design and callout management. Let’s evaluate the options based on their suitability for these business requirements.
Key Considerations:
➡️ The external web service’s long response time requires an asynchronous callout mechanism to avoid exceeding Salesforce’s synchronous callout limit (10 seconds).
➡️ User input collection suggests a front-end interface where the end user provides key inputs before the callout is initiated.
➡️ The solution should integrate seamlessly within Salesforce, likely via a Lightning-based interface.
Evaluation of Options:
A. Lightning web component
A Lightning Web Component (LWC) provides a modern, customizable user interface for collecting key inputs from the end user (e.g., via lightning-input fields). It can be embedded in a Lightning page or app and paired with an Apex method to handle the callout. While LWC itself does not manage long-running callouts, it can initiate them asynchronously, making it a suitable front-end element for user interaction. This is a strong candidate for the first element.
B. Apex method that returns a Continuation object
The Continuation class in Apex supports long-running callouts by allowing asynchronous HTTP requests with a timeout of up to 120 seconds, far exceeding the synchronous limit. An Apex method annotated with @AuraEnabled and returning a Continuation object can be called from a Lightning component, initiating the callout and providing a callback mechanism to handle the response. This is the ideal backend solution for managing the long response time, making it a strong candidate for the second element.
C. Screen Flow
A Screen Flow provides a guided, interactive interface to collect user inputs through screens, which could be used to gather the key inputs. However, Flows are not designed to handle long-running callouts directly; they can invoke Apex, but the callout logic would still need to be managed asynchronously (e.g., via Continuation or Queueable). While feasible, this approach adds complexity compared to a dedicated LWC, and Flows are better suited for process automation rather than custom integration logic, making it less optimal.
D. Process Builder
Process Builder is a declarative tool for automating business processes based on record changes. It cannot collect user inputs in real-time or handle long-running callouts, as it lacks interactive screens and callout capabilities beyond synchronous limits. This option is unsuitable for both requirements (user input collection and long-running callouts).
Correct Answers: A. Lightning web component and B. Apex method that returns a Continuation object
A Lightning Web Component is the optimal front-end element to collect key inputs from the end user, providing a responsive and customizable interface. An Apex method returning a Continuation object is the recommended backend solution to manage the long-running callout, allowing the system to wait for the external web service’s response without hitting governor limits. Together, the LWC can gather inputs, pass them to the Apex method, and handle the asynchronous response, aligning with the Salesforce Platform Developer II exam’s “User Interface” and “Integration” domains.
Reference:
Salesforce LWC Developer Guide - Lightning Web Components, Salesforce Apex Developer Guide - Continuation Class.
Additional Notes:
To implement, create an LWC with input fields to collect user data, use an @wire or imperative Apex call to invoke the Continuation-based method (e.g., @AuraEnabled(continuation=true)), and define a callback in the LWC to process the response. The Apex method would set up the HttpRequest, return a Continuation object with a timeout, and update the record or UI upon response. This ensures a seamless user experience despite the long response time.
Which three approaches should a developer implement to obtain the best performance for data retrieval when building a Lightning web component? (Choose 3 answers)
A. Use lazy load for occasionally accessed data.
B. Use layoutTypes: 9'Full') to display a set of fields.
C. Use the Lightning Data Service.
D. Use getRecordUi to obtain metadata.
E. Use {Cacheable=true} whenever possible
C. Use the Lightning Data Service.
E. Use {Cacheable=true} whenever possible
Explanation:
✅ A. Use lazy load for occasionally accessed data
➡️ Why it helps: Lazy loading defers loading data until it’s actually needed, which improves initial load time and reduces unnecessary server calls.
➡️ Use case: When data is only needed upon user interaction (e.g., expanding a section or switching tabs), lazy loading improves performance.
➡️ Result: Faster initial render and optimized use of resources.
✅ C. Use the Lightning Data Service
➡️ Why it helps: Lightning Data Service (LDS) loads, caches, and shares record data without requiring Apex.
➡️ It avoids server round trips and handles field-level security and sharing automatically.
➡️ Result: High-performance, low-maintenance data access aligned with platform standards.
✅ E. Use {cacheable=true} whenever possible
➡️ Why it helps: When an Apex method is annotated with @AuraEnabled(cacheable=true), results are cached on the client side.
➡️ This reduces unnecessary Apex calls for data that doesn’t change frequently.
➡️ Result: Faster response time and reduced server load.
❌ Why the other options are incorrect:
❌ B. Use layoutTypes: 'Full' to display a set of fields
➜ This option refers to a metadata-driven UI feature, but using layoutTypes like 'Full' can return more fields than necessary, leading to over-fetching.
➜ It’s not performance optimized compared to fetching only specific fields using getRecord.
❌ D. Use getRecordUi to obtain metadata
➜ getRecordUi is useful for fetching layout and metadata, but it returns a lot of data, which can impact performance if used frequently or for high-volume pages.
➜ Not optimal for regular data retrieval—it’s better for dynamic form generation, not bulk performance.
📚 Reference:
Lightning Web Components Performance Best Practices
LDS vs Apex Data Access
@AuraEnabled(cacheable=true) – Apex Documentation
🧠 Key Takeaway:
Use lazy loading, Lightning Data Service, and cacheable Apex methods to get the best performance in Lightning Web Components. Avoid over-fetching metadata or fields you don't need.
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.
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.
Consider the following code snippet:
Which two steps should the developer take to add flexibility to change the endpoint and
credentials without needing to modify code?
(Choose 2 answers)
A. Use req. setindpoint ('callout:endFoint_NC'); within the callout request.
B. Store the URL of the endpoint in a custom Label named endpointuRL.
C. Create a Named Credential, endPcint_wc, ta store the endpoint and credentials.
D. Use red. setEndpoint (Label.endPointURL) ;.
C. Create a Named Credential, endPcint_wc, ta store the endpoint and credentials.
Explanation:
A. Use req.setEndpoint('callout:endPoint_NC'); within the callout request.
This option suggests using a Named Credential (endPoint_NC) to handle the endpoint. Named Credentials in Salesforce allow you to store endpoint URLs and authentication details (like username and password) securely. By using callout: syntax, the endpoint and credentials can be managed in the Named Credential settings, which can be updated without changing the code. This is a best practice for flexibility and security.
B. Store the URL of the endpoint in a custom Label named endpointURL.
Custom Labels allow you to store static values (like URLs) that can be accessed in Apex code using Label.endpointURL. This approach enables the endpoint to be changed via the Salesforce UI (under Custom Labels) without code modification, adding flexibility.
C. Create a Named Credential, endPoint_NC, to store the endpoint and credentials.
This is a valid and recommended approach. Named Credentials can store both the endpoint URL and authentication details (e.g., username and password), which can be updated in the Salesforce setup without altering the Apex code. Using req.setEndpoint('callout:endPoint_NC'); would leverage this configuration.
D. Use req.setEndpoint(Label.endPointURL);
This option builds on option B, where the endpoint URL is stored in a Custom Label (endpointURL). By referencing Label.endPointURL in the code, the developer can update the URL in the Custom Label configuration, avoiding code changes. However, this does not address credentials, which are hardcoded in the original snippet.
Correct Answers:
✅ A. Use req.setEndpoint('callout:endPoint_NC'); within the callout request.
This leverages a Named Credential to manage both the endpoint and credentials dynamically.
✅ C. Create a Named Credential, endPoint_NC, to store the endpoint and credentials.
This sets up the Named Credential that supports option A, providing a secure and flexible way to handle both endpoint and authentication.
Why Not B and D?
❌ B: only addresses the endpoint URL and not the credentials, which are also hardcoded in the snippet (e.g., myUserName and strongPassword). It’s a partial solution.
❌ D: depends on a Custom Label for the endpoint but still requires manual handling of credentials, making it less comprehensive than using Named Credentials.
ℹ️ References:
➡️ Salesforce Documentation on Named Credentials
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.