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
Refer to the test method below:

A. Option A
B. Option B
C. Option C
D. Option D
Explanation:
In Apex, test methods cannot perform real HTTP callouts. To test functionality that includes a callout, Salesforce requires you to use Test.setMock() along with Test.startTest() and Test.stopTest() to simulate the callout behavior.
Here’s what needs to happen:
Test.setMock() tells the test framework to use a mock response for a given HTTP callout.
Test.startTest() isolates the test’s execution context, ensuring that governor limits are reset.
Test.stopTest() ensures any asynchronous and final operations (like callouts) are executed and completed before assertions are made.
By placing Test.setMock() after startTest() and before the callout, and using stopTest() after the callout, the test can simulate the integration without performing an actual web service call, preventing the "Web service callouts not supported" error.
Test.startTest();
Test.setMock(HttpCalloutMock.class, new YourMockResponseClass());
CalloutUtil.sendAccountUpdate(acct.Id);
Test.stopTest();
This approach is Salesforce best practice for testing callouts.
❌ Incorrect Answers:
A) Add if (!Test.isRunningTest()) around CalloutUtil.sendAccountUpdate.
This option attempts to bypass the callout during tests by checking if the code is running in a test context. While Test.isRunningTest() does return true in test methods, this strategy essentially skips the logic you're trying to test, which defeats the purpose of the unit test. It doesn’t verify the correctness of the code path or simulate the response from the callout, and leaves important logic untested. Salesforce recommends mocking callouts, not bypassing them, to maintain test reliability and coverage.
B) Add Test.startTest() and Test.setMock() before and Test.stopTest() after CalloutUtil.sendAccountUpdate.
This is almost correct but it's missing a critical detail: the order of Test.setMock() matters. It must be called after Test.startTest() to ensure the mock context is properly initialized. If you call setMock() before startTest(), it may not function correctly depending on the Salesforce runtime behavior. This can cause the mock to be ignored and a real callout attempted — which leads to the same error. Option C correctly reflects the sequence: startTest() → setMock() → perform callout → stopTest().
D) Add Test.startTest() before and Test.stopTest() after CalloutUtil.sendAccountUpdate.
This option correctly uses startTest() and stopTest(), but omits Test.setMock(), which is essential. Without mocking, the test will still attempt a real HTTP callout, which is not permitted in test context and will fail with the same error. Using startTest() and stopTest() is not enough on its own — a mock class that implements HttpCalloutMock must be registered using Test.setMock() to simulate a response. Therefore, this solution is incomplete and will not solve the problem.
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 tag should a developer use to display different text while an apex:commandbutton is Processing an action?
A. apex:actionSupparts
B. apex:actionPaller
C. apex:actionStatus
D. apex:pageMes sagas
Explanation:
To determine which tag is appropriate, we need to understand how a Visualforce page can provide dynamic user feedback when an action is invoked — such as clicking a button that performs an Apex action. Visualforce offers certain components specifically designed for these kinds of interactions. The goal here is to show different text (like "Processing..." or a loading spinner) while the button action is running — this requires detecting the start and end of an action.
A. apex:actionSupparts
This is likely a typo of apex:actionSupport, a real Visualforce component. Assuming that’s the case, apex:actionSupport is used to add AJAX behavior to other components, like apex:inputText. It can call a controller method in response to client-side events (like onkeyup or onclick), and it can optionally work with apex:actionStatus to show feedback. However, on its own, actionSupport does not display any status or message — it only triggers actions. Therefore, it’s not the correct tag to show “processing” text directly, although it might be part of a broader solution.
B. apex:actionPaller
This is a misspelling of apex:actionPoller, which is a legitimate Visualforce tag. apex:actionPoller repeatedly calls a controller action at a defined interval (like every 5 seconds), commonly used for polling server-side data updates. This is not used for handling a single button click or showing feedback during that click. It has no native connection to a button press or a way to show temporary "processing" text. So, this option is incorrect, both in purpose and due to the misspelling.
✅ C. apex:actionStatus
This is the correct answer. apex:actionStatus is a Visualforce component specifically designed to show different content depending on whether an AJAX action (such as from apex:commandButton or apex:actionFunction) is in progress or has completed. You can define two parts inside it:
D. apex:pageMessages
apex:pageMessages displays messages such as errors, warnings, and info messages returned by Apex (like using ApexPages.addMessage()). While it's essential for error feedback, it does not track or display processing status, nor does it change based on action timing. It simply renders server messages after an action completes. Therefore, it cannot be used to show "Loading..." or other temporary UI changes. This makes it incorrect for this question.
✅ Correct Answer: C. apex:actionStatus
🧩 Reason:
apex:actionStatus is the only Visualforce tag built specifically to manage UI changes based on the status of an asynchronous action (like a button click). It provides a clean way to show dynamic feedback, like "Processing…" or a spinner, while the action is being handled on the server. It integrates with apex:commandButton via the status attribute and allows declarative control over both the "start" and "stop" phases of the action.
ℹ️ Reference:
Salesforce Developer Guide – apex:actionStatus
A developer wants to write a generic Apex method that will compare the Salesforce Name field between any two object records. For example, to compare the Name field of an Account and an Opportunity; or the Name of an Account and a Contact. Assuming the Name field exists, how should the developer do this?
A. Cast each object into an sObject and use sObject.get to compare the Name fields.
B. describe) function to compare the values of each Name field.
C. Use the Salesforce Metadata API to extract the value of each object and compare the Name fields.
D. Use a string. Replace () method to parse the contents of each Name field and then compare the results.
Explanation:
To create a generic Apex method that compares the Name field between any two object records (e.g., Account and Opportunity, or Account and Contact), the developer needs a solution that works across different Salesforce objects, assuming the Name field exists. The method must handle the polymorphic nature of Salesforce objects while accessing their Name fields. Let’s evaluate the options based on their feasibility, correctness, and alignment with Salesforce best practices.
✅ A. Cast each object into an sObject and use sObject.get to compare the Name fields.
In Apex, any Salesforce object can be treated as an sObject, the generic type for all Salesforce records. By casting the input objects to sObject, the developer can use the sObject.get('Name') method to dynamically retrieve the value of the Name field, regardless of the specific object type (e.g., Account, Opportunity, Contact). This approach is flexible and generic, as it doesn’t require hardcoding object-specific logic. The retrieved values (typically strings for the Name field) can then be compared using standard Apex comparison methods (e.g., == or String.equals()). This is a straightforward and idiomatic way to handle cross-object field access in Apex.
➥ Reference: Salesforce Apex Developer Guide - sObject Methods.
❌ B. describe() function to compare the values of each Name field.
There is no describe() function in Apex. The correct term is Schema.describeSObjects() or Schema.getGlobalDescribe(), which provides metadata about objects and fields. While these methods can confirm whether the Name field exists for a given object, they are not designed to retrieve or compare field values from specific records. Using describe calls for this purpose would be indirect and inefficient, as they focus on schema metadata, not record data. This option is incorrect due to the nonexistent “describe() function” and its irrelevance to comparing field values.
➥ Reference: Salesforce Apex Developer Guide - Schema Class.
❌ C. Use the Salesforce Metadata API to extract the value of each object and compare the Name fields.
The Salesforce Metadata API is used for managing org configuration, such as creating or modifying objects, fields, and layouts, not for accessing record data like the Name field values. To compare record-specific field values, the Metadata API is inappropriate, as it operates on metadata, not instance data. This approach is incorrect and impractical for the requirement, as it cannot retrieve or compare field values from specific records.
➥ Reference: Salesforce Metadata API Developer Guide - Overview.
❌ D. Use a String.replace() method to parse the contents of each Name field and then compare the results.
The String.replace() method is used for manipulating string values, such as replacing substrings. It is not a mechanism for accessing or retrieving field values from Salesforce records. To compare Name fields, the developer first needs to access the field values, which String.replace() cannot do. Additionally, parsing or manipulating the Name field with replace() is unnecessary for a simple comparison, making this option irrelevant and incorrect.
➥ Reference: Salesforce Apex Developer Guide - String Methods.
✅ Correct Answer: A. Cast each object into an sObject and use sObject.get to compare the Name fields.
Reason: Casting the input objects to sObject and using the sObject.get('Name') method is the best practice for writing a generic Apex method to compare the Name fields of any two records. This approach leverages the polymorphic nature of sObject to work with any Salesforce object that has a Name field, ensuring flexibility and reusability. The get method retrieves the Name field value dynamically, and the values can be compared as strings. This aligns with the Salesforce Platform Developer II exam’s focus on “Apex Programming” and handling dynamic data access.
Additional Notes:
The developer should ensure the Name field exists for the objects being compared, as not all standard or custom objects have a Name field (e.g., junction objects may not). To make the method robust, they could use Schema.describeSObjects() to verify the Name field’s existence before comparison, but this isn’t required for the basic comparison logic. The method signature might take two sObject parameters, and the comparison could be implemented as follows (noting your request to avoid code, this is for context): accept two sObject records, use get('Name') to retrieve values, and compare them with String.equals() or ==. This approach is efficient and aligns with Apex best practices for generic programming.
A Salesforce developer is hired by a multi-national company to build a custom Lightning application that shows employees their employment benefits and earned commissions over time. The application must acknowledge and respect the user's locale context for dates, times, numbers, currency, and currency symbols. When using Aura components, which approach should the developer implement to ensure the Lightning application complies with the user's locale?
A. Use the $User global variable to retrieve the user preferences.
B. Use the $Label global value provider.
C. Use the $Lacale value provider to retrieve the user preferences.
D. Create a Hierarchical custom setting to store user preferences.
Explanation:
To ensure that a Lightning application respects the user's locale settings—including dates, times, numbers, currency formats, and symbols—the most effective and standard approach in Aura components is to use the $Locale global value provider.
Aura provides several global value providers (GVPs), and $Locale specifically returns data that corresponds to the user’s locale, such as:
🧩 decimal – the decimal separator (e.g., "." or ",")
🧩 currency – the user’s currency code (e.g., USD, EUR)
🧩 currencyFormat – the display format for currency
🧩 dateFormat, shortDateFormat, longDateFormat
🧩 language – user’s language
🧩 timezone – user's timezone
These values are automatically derived from the logged-in user's locale and language settings in Salesforce, making it the best way to ensure the UI aligns with local formatting expectations.
❌ Why the other options are incorrect:
A. Use the $User global variable to retrieve the user preferences
The $User variable is used to retrieve user-specific information (like name, role, email), but not locale-specific formatting like date/currency. It doesn't give access to formatting details required for this task.
B. Use the $Label global value provider
$Label is for accessing custom labels, which are helpful for translations and static text, but not dynamic locale-based formatting like currency or number formats.
D. Create a Hierarchical custom setting to store user preferences
While possible, this is not scalable or maintainable, and duplicates functionality already built into Salesforce via $Locale. It adds unnecessary complexity and lacks automatic updates if the user changes their locale settings.
🧠 Summary:
For an Aura component to automatically reflect local formatting based on the user's preferences, $Locale is the built-in, optimized, and standard way to achieve it. It requires minimal effort, and ensures your application remains consistent with Salesforce UX standards across all regions.
✅ Final Answer:
C. Use the $Locale value provider to retrieve the user preferences
Reference:
Salesforce Developer Guide – Global Value Providers in Aura 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.