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 Release
202 Questions
4.9/5.0

Which technique can run custom logic when a Lightning web component is loaded?

A. Use an init event to call a function.

B. Use the randersd loack { } method.

C. Call 52. engqueusiction and pass in the method to call.

D. Use the connectedCallback { } method.

D.   Use the connectedCallback { } method.

Explanation:

❌ A. Use an init event to call a function: There is no standard init event in Lightning Web Components (LWC). In Aura components, the init event () is used to run logic on component initialization, but this is not applicable to LWC, making this option incorrect.

❌ B. Use the randersd loack { } method: This option is likely a typo for renderedCallback(). The renderedCallback() method runs after a component’s DOM is updated, not when the component is initially loaded (inserted into the DOM). While useful for post-rendering logic, it’s not the best choice for initialization logic, and the typo makes this option invalid.

❌ C. Call 52. engqueusiction and pass in the method to call: This appears to be a typo for Apex.enqueueAction or a similar concept from Aura components, but no such method exists in LWC. In LWC, Apex methods are called using @wire or imperative Apex calls, not for initialization logic. This option is incorrect due to its invalid syntax and irrelevance.

✅ D. Use the connectedCallback() method: The connectedCallback() lifecycle method in LWC is invoked when the component is inserted into the DOM, making it the ideal place to run custom initialization logic (e.g., fetching data, setting initial state). This method is part of LWC’s lifecycle hooks and is the standard approach for executing logic when the component loads.

Reason: The connectedCallback() method is the correct technique for running custom logic when an LWC is loaded, as it executes when the component is added to the DOM. This aligns with the Platform Developer II exam’s “User Interface” domain and LWC lifecycle management.

Reference: Salesforce LWC Developer Guide - Lifecycle Hooks.

A corporation has many different Salesforce orgs, with some different objects and some common objects, and wants to build a single Java application that can create, retrieve, and update common object records in all of the different orgs. Which method of integration should the application use?

A. SOAP API with the Partner WSDL

B. Apex REST Web Service

C. SOAP API with the Enterprise WSDL

D. Metadata APT

A.   SOAP API with the Partner WSDL

Explanation:

The company has multiple Salesforce orgs with some different and some common objects, and a Java application needs to create, retrieve, and update common object records across all orgs. The integration method must be flexible and org-agnostic.

Option A: SOAP API with the Partner WSDL The Partner WSDL is a loosely typed, generic WSDL that works across different Salesforce orgs, regardless of their specific object schemas. It allows the Java application to dynamically discover and interact with common objects (e.g., Account, Contact) using standard SOAP API calls. This is ideal for a single application interacting with multiple orgs with varying configurations.

Option B: Apex REST Web Service Apex REST Web Services are custom RESTful services defined in Apex, specific to a single org’s implementation. This requires each org to expose compatible endpoints, which is impractical for multiple orgs with different schemas and would require significant customization per org.

Option C: SOAP API with the Enterprise WSDL The Enterprise WSDL is strongly typed and generated based on a specific org’s schema, including its custom objects and fields. It is not portable across orgs with different configurations, making it unsuitable for a single application to handle multiple orgs.

Option D: Metadata API The Metadata API is used to manage metadata (e.g., custom objects, fields) rather than runtime data operations like create, retrieve, and update. It is not designed for record-level interactions.

Why Option A is Best:
The Partner WSDL provides a flexible, org-agnostic interface, allowing the Java application to adapt to the common objects across different orgs without requiring org-specific customization.

References:
Salesforce Developer Guide: Partner WSDL

A company has code to update a Request and Request Lines and make a callout to their external ERP system's REST endpoint with the updated records.

The callousUtil.makeRestCallout fails with a "You have uncommitted work pending. Please commit or rollback before calling cut’ error. What should be done to address the problem?

A. Change the callousUtil makeRestCallout to an @InvocsblsMethod method.

B. Remove the Database. setSavepoint and Database. rollback.

C. Change the CallousUtill .makeRestCallout to an @future method.

C.   Change the CallousUtill .makeRestCallout to an @future method.

✅ Explanation:

The error message:
➥ "You have uncommitted work pending. Please commit or rollback before calling out"
...indicates that a DML operation (like insert/update) was performed before an HTTP callout, which is not allowed in synchronous Apex.

🧠 Why This Happens:
Apex enforces a "DML before callout" restriction in synchronous transactions.

In your code:
➥ You perform insert operations for reqs and reqLines.
➥ Then you make a callout using CalloutUtil.makeRestCallout(...).
➥ This causes the runtime to throw the error because uncommitted DML has occurred before the callout.

✅ How @future Helps
By marking the callout method as @future(callout=true), you:
➥ Move the callout logic to an asynchronous context.
➥ Avoid the DML-before-callout restriction.
➥ Allow the synchronous part to finish (i.e., insert the records), and then the callout is made separately after the transaction completes.

❌ Why the Other Options Are Incorrect

A. Change to @InvocableMethod
➥ @InvocableMethod is used for Flow and Process Builder integration.
➥ It does not solve the DML-before-callout error.
➥ Also, @InvocableMethod does not inherently run asynchronously or allow callouts unless combined with future or Queueable context.

B. Remove Database.setSavepoint() and rollback()
➥ These lines handle transaction rollback and are not related to the DML-callout restriction.
➥ Removing them won't fix the error — you'd still be making a callout after a DML operation.

📘 Reference Documentation
Apex Callouts Best Practices
@future Annotation
DML and Callout Order

Which three actions must be completed in a Lightning web component for a JavaScript file In a static resource to be loaded?
(Choose 3 answers)

A. Import the static resource.

B. Reference the static resource in a <script> tag.

C. Call loadScript.

D. Import a method from the platformResourceLoader.

E. Append the static resource to the DOM.

A.   Import the static resource.
C.   Call loadScript.
D.   Import a method from the platformResourceLoader.

Explanation:

To determine the three actions that must be completed in a Lightning Web Component (LWC) for a JavaScript file in a static resource to be loaded, we need to understand how LWC handles the inclusion of external JavaScript files stored as static resources. LWC enforces a secure and controlled environment, requiring specific steps to load and use such resources dynamically. Let’s evaluate the options based on Salesforce’s LWC development guidelines.\

Key Considerations:
✔ Static resources in Salesforce are files (e.g., JavaScript, CSS) uploaded to the org and accessed via a unique URL.
✔ LWC does not allow direct inclusion of external scripts via <script> tags in the HTML file due to security and modularization constraints.
✔ The platformResourceLoader module provides a secure method to load static resource files asynchronously in LWC.

Evaluation of Options:

A. Import the static resource.
LWC uses the import statement to reference static resources by their name (e.g., import myResource from '@salesforce/resourceUrl/MyStaticResource';). This retrieves the URL of the static resource, which is necessary as the first step to load the JavaScript file. This action is required to make the resource accessible in the component.

B. Reference the static resource in a <script> tag.
Adding a <script> tag with a src attribute pointing to the static resource is not supported in LWC HTML files. LWC’s security model prevents direct script inclusion, requiring the use of platformResourceLoader instead. This option is incorrect.

C. Call loadScript.
The loadScript method from the platformResourceLoader module is used to asynchronously load a JavaScript file from a static resource. After importing the resource URL, loadScript(this, resourceUrl).then(() => {...}) executes the script, making it available in the component. This action is required to complete the loading process.

D. Import a method from the platformResourceLoader.
The platformResourceLoader module must be imported (e.g., import { loadScript } from 'lightning/platformResourceLoader';) to access methods like loadScript. This step is essential to enable the component to load the static resource’s JavaScript file, making it a required action.

E. Append the static resource to the DOM.
Appending the static resource to the DOM (e.g., via document.createElement('script')) is not a supported or recommended approach in LWC. The loadScript method handles the loading and execution securely, and manual DOM manipulation violates LWC’s component lifecycle and security model. This option is incorrect.

Correct Answers: A. Import the static resource, C. Call loadScript, and D. Import a method from the platformResourceLoader.

To load a JavaScript file from a static resource in an LWC, the developer must:
✔ Import the static resource using import myResource from '@salesforce/resourceUrl/MyStaticResource'; to get its URL.
✔ Import a method (e.g., loadScript) from lightning/platformResourceLoader to enable the loading functionality.
✔ Call loadScript with the component context and resource URL to load and execute the script asynchronously.
These steps ensure secure and proper integration, aligning with the Salesforce Platform Developer II exam’s “User Interface” domain, particularly LWC development.

Reference: Salesforce LWC Developer Guide - Load Static Resources and platformResourceLoader.

Additional Notes: The implementation would involve importing the resource and loadScript in the JS file, calling loadScript in the connectedCallback or a user action, and handling the .then() callback to use the loaded script. Ensure the static resource is a valid ZIP file with the JavaScript file, and test for errors (e.g., using .catch()). This approach maintains LWC’s security and performance standards.

Business rules require a Contact ta always be created when a new Account is created. What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?

A. Use setSaverpoint (1) and rollback() with a try-catch block.

B. Use the Database. Insect method with a11orNone SEL LO alee,

C. Use the Database. Delete method if the Contact insertion fails.

D. Disable validation rules on Contacts and set default values with a trigger.

A.   Use setSaverpoint (1) and rollback() with a try-catch block.

Explanation:

To ensure an Account is not created if the creation of the Contact fails, per the business rules, we need a mechanism that guarantees both the Account and Contact are created successfully or neither is created. Let’s evaluate the options:

✅ A. Use setSavepoint() and rollback() with a try-catch block.
In Salesforce, setSavepoint() and rollback() are used to manage database transactions. By setting a savepoint before attempting to insert the Account and Contact, you can rollback the entire transaction if the Contact creation fails, ensuring no Account is created. A try-catch block allows you to handle any exceptions during the Contact insertion and trigger the rollback. This approach ensures atomicity—either both records are created, or neither is.
➜ Why it works: This method provides full control over the transaction, preventing partial commits.
➜ Reference: Salesforce Apex Developer Guide - Transaction Control.

❌ B. Use the Database.insert method with allOrNone set to false.
The Database.insert method with allOrNone = false allows partial success, meaning if the Contact insert fails, the Account might still be created. This does not meet the requirement, as the business rule mandates that no Account should be created if the Contact creation fails.
➜ Why it’s incorrect: This approach does not enforce atomicity, as it allows the Account to be committed even if the Contact fails.
➜ Reference: Salesforce Apex Developer Guide - Database Methods

❌ C. Use the Database.delete method if the Contact insertion fails.
This option suggests inserting the Account, and if the Contact insert fails, deleting the Account using Database.delete. While this could work, it’s less efficient and riskier than using a transaction with setSavepoint() and rollback(). Deleting the Account after insertion introduces unnecessary DML operations and could fail due to other triggers or validation rules, leaving the database in an inconsistent state.
➜ Why it’s suboptimal: It’s not a clean transactional approach and could lead to issues if other processes reference the Account before deletion.
➜ Reference: Salesforce Apex Developer Guide - DML Operations.

❌ D. Disable validation rules on Contacts and set default values with a trigger.
Disabling validation rules and setting default values via a trigger does not address the requirement of ensuring the Account is not created if the Contact creation fails. This approach might make Contact creation more likely to succeed by bypassing validations, but it doesn’t provide a mechanism to rollback the Account creation if the Contact insert still fails.
➜ Why it’s incorrect: It doesn’t enforce the transactional dependency between the Account and Contact.
➜ Reference: Salesforce Help - Validation Rules.

✅ Correct Answer: A. Use setSavepoint() and rollback() with a try-catch block.
➜ Reason: This option ensures transactional integrity by rolling back both the Account and Contact insertions if the Contact creation fails, directly addressing the business rule. It’s the most robust and recommended approach in Apex for handling such scenarios.

ℹ️ Additional Notes:
➜ This question tests knowledge of Apex transaction control, a key topic in the Salesforce Platform Developer II exam, particularly in the “Data Integration and Management” and “Apex Programming” domains.
➜ Ensure you understand how to implement setSavepoint() and rollback() in a custom controller or Apex class for a custom screen, as this is a common use case in Visualforce or Lightning 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

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.