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

A developer wrote a trigger on Opportunity that will update a custom Last Sold Date field on the Opportunity's Account whenever an Opportunity is closed. In the test class for the trigger, the assertion to validate the Last Sold Date field fails. What might be causing the failed assertion?

A. The test class has not defined an Account owner when inserting the test data.

B. The test class has not implemented seealldata=true in the test method.

C. The test class has not re-queried the Account record after updating the Opportunity.

D. The test class is not using System. runs () to run tests as a Salesforce administrator.

C.   The test class has not re-queried the Account record after updating the Opportunity.

Explanation:

To understand why the assertion fails in this trigger test scenario, we need to focus on how data is handled in Apex tests, especially regarding trigger behavior and record state in memory vs. the database.

✅ Correct Answer: C. The test class has not re-queried the Account record after updating the Opportunity.

✅ Explanation:
When you update a record in Apex (like an Opportunity), any related changes made by triggers (like updating a field on the parent Account) occur in the database. However, the in-memory version of the Account (from earlier in the test method) does not automatically reflect those changes.
So, if your trigger updates the Last_Sold_Date__c field on Account when an Opportunity is closed, but the test class does not perform a fresh SOQL query to retrieve the updated Account, then any assertion against that field will still reflect the old value (likely null) — causing the test to fail.

✅ Proper fix in the test class:
Account acct = [SELECT Id, Last_Sold_Date__c FROM Account WHERE Id = :accountId];
System.assertEquals(expectedDate, acct.Last_Sold_Date__c);

🔗 Reference: Salesforce Developer Docs – Testing Triggers

❌ A. The test class has not defined an Account owner when inserting the test data.
This is not necessary unless your trigger or validation rules explicitly depend on OwnerId. Salesforce assigns a default owner (usually the running user) if none is provided. So this won’t affect the Last_Sold_Date__c update unless additional logic is involved (not mentioned here).

❌ B. The test class has not implemented seeAllData=true in the test method.
Using seeAllData=true is discouraged and unnecessary here. Since you're inserting test Account and Opportunity records within the test method, no real org data is required. The test should work with only mock/test data.

❌ D. The test class is not using System.runAs() to run tests as a Salesforce administrator.
System.runAs() is used to test behavior under different user roles or profiles (e.g., field-level security or sharing rules). It is not required for triggers to function unless access issues are part of the logic. Again, this isn’t relevant in the scenario described.

✅ Final Verdict:
C. The test class has not re-queried the Account record after updating the Opportunity is the correct answer because without re-querying, the test accesses stale data, leading to a failed assertion.

Universal Containers implements a private sharing model for the Convention Attendee co custom object. As part of a new quality assurance effort, the company created an Event_Reviewer_c user lookup field on the object. Management wants the event reviewer to automatically gain ReadWrite access to every record they are assigned to. What is the best approach to ensure the assigned reviewer obtains Read/Write access to the record?

A. Create a before insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.

B. Create an after insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.

C. Create criteria-based sharing rules on the Convention Attendee custom object to share the records with the Event Reviewers.

D. Create a criteria-based sharing rule on the Convention Attendee custom object to share the records with a group of Event Reviewers.

B.   Create an after insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.

Explanation:

✅ Correct Answer: B — After insert trigger with Apex Sharing Reasons and Managed Sharing
🔐 Why this works:
When implementing Apex Managed Sharing, Salesforce requires that the record already exist in the database so it has a valid record ID. This ID is necessary for creating a custom Share record that links the record to the user in the Event_Reviewer__c field. Because of this, the logic to share the record must happen after the insert — which is why the correct place is an after insert trigger.

🛠 Managed Sharing gives full control over access logic in Apex. By using a custom Apex Sharing Reason, you can apply named reasons for the share (e.g., “Assigned Reviewer Access”), and admins can later manage them through the UI if needed. This also keeps sharing logic dynamic and scalable, suitable for future changes.

📚 Use Case Fit:
This solution supports the requirement that access is automatically granted when a user is assigned as a reviewer. It works with private sharing models, ensures proper access is granted without compromising security, and is admin-friendly due to its maintainability.

❌ A — Before insert trigger with Apex Managed Sharing
🚫 Why it's wrong:
In a before insert trigger, the record does not yet have a Salesforce ID, which is essential to create a valid Share object in Apex. Since Apex Managed Sharing requires the ParentId (record ID) to associate the shared record to the target user, this method fails technically. The trigger would attempt to share a record that doesn’t yet exist — leading to runtime errors or unintended behavior.

💡 Key Concept:
Sharing must occur after the database transaction, which makes this a clear architectural limitation of before triggers.

❌ C — Criteria-based sharing rule for Event Reviewers
🚫 Why it's wrong:
Criteria-based sharing rules can only apply access based on record field values — not based on dynamic user lookups like Event_Reviewer__c. You can’t configure them to assign access directly to the user listed in a lookup field. They also only support role, group, or public access, not individual user-based field references.

⚠️ Limitation:
They are designed for bulk sharing to groups of users, not one-to-one sharing based on lookup assignments. Therefore, they can’t fulfill the requirement to grant access dynamically to the user assigned.

❌ D — Share with a group of Event Reviewers
🚫 Why it's wrong:
This would share every Convention Attendee record with a static group of users, regardless of who is assigned as Event_Reviewer__c. This does not meet the requirement of only granting access to the specific assigned reviewer. Also, if reviewers change or rotate frequently, managing group membership would become cumbersome and error-prone.

📉 Problem:
It lacks flexibility, introduces overhead, and fails to dynamically reflect the lookup field changes.

Reference:
Apex Managed Sharing

A developer created 2 class that implements the Queueable Interface, as follows:
As part of the deployment process, the developer is asked to create a corresponding test class.
Which two actions should the developer take to successfully execute the test class?
(Choose 2 answers)

A. Implement seeAllData=True to ensure the Queueable job is able to run in bulk mode.

B. Ensure the running user of the test class has, at I the View All permission on the Order object.

C. Enclose System.enqueueJob(new OrderQueueableJob ()] within Tess. and Test .stopTest (1.

D. Implement Test. isRunningTest() to prevent chaining jobs during test execution.

C.   Enclose System.enqueueJob(new OrderQueueableJob ()] within Tess. and Test .stopTest (1.
D.   Implement Test. isRunningTest() to prevent chaining jobs during test execution.

Explanation:

To successfully execute a test class for two classes that implement the Queueable interface as part of the deployment process, the developer needs to ensure proper testing of asynchronous Apex jobs. Let’s analyze the options and determine the two correct actions.
Correct Answers: C and D

Option A: Implement seeAllData=True to ensure the Queueable job is able to run in bulk mode. Using seeAllData=true allows the test class to access all data in the organization, which is generally discouraged in Salesforce testing. Best practices recommend creating test data within the test class using @TestSetup or within the test method itself to ensure isolated and repeatable tests. Additionally, seeAllData=true does not specifically enable bulk mode for Queueable jobs; bulk mode is handled by the design of the Queueable class and the volume of data processed. This option is incorrect.

Option B: Ensure the running user of the test class has, at a minimum, the View All permission on the Order object. The running user’s permissions (e.g., View All on the Order object) are not directly relevant to executing a Queueable job in a test context. Test classes run in an isolated environment with system context, where permissions are bypassed unless explicitly enforced. The focus should be on testing the Queueable logic, not user permissions. This option is incorrect.

Option C: Enclose System.enqueueJob(new OrderQueueableJob()) within Test.startTest() and Test.stopTest(). To test a Queueable job, the System.enqueueJob() call must be placed between Test.startTest() and Test.stopTest(). This ensures that the asynchronous job is executed synchronously within the test context, allowing the developer to verify the job’s behavior and assert the results. Test.stopTest() forces the execution of all asynchronous processes (including Queueable jobs) queued by Test.startTest(), which is essential for validating the job’s success or failure. This is a standard practice for testing asynchronous Apex and is a correct action.

Option D: Implement Test.isRunningTest() to prevent chaining jobs during test execution. Queueable jobs can chain other Queueable jobs by calling System.enqueueJob() within their execution. However, during test execution, chaining can lead to unpredictable behavior or exceed governor limits. Using if (!Test.isRunningTest()) within the Queueable class prevents chaining when the code is running in a test context, ensuring the test focuses on the primary job without triggering additional jobs. This is a recommended technique for managing Queueable job tests and is a correct action.

Why Options C and D are Best:

Option C ensures the Queueable job is executed and tested within the test method by leveraging Test.startTest() and Test.stopTest(). This is a fundamental requirement for testing asynchronous Apex, including Queueable jobs, as it allows assertion of results after the job completes.
Option D addresses the potential issue of job chaining, which can complicate test execution. By using Test.isRunningTest(), the developer can disable chaining during tests, keeping the test scope manageable and compliant with governor limits.

Example Approach:
The developer should structure the test class to create test data, enqueue the Queueable job within Test.startTest() and Test.stopTest(), and use Test.isRunningTest() in the Queueable class to avoid chaining. This ensures the test runs successfully and validates the intended behavior.

Reference:
1. Salesforce Documentation - Testing Asynchronous Apex:
Testing Queueable Apex
Details the use of Test.startTest() and Test.stopTest() for testing Queueable jobs.

2. Salesforce Documentation - Test.isRunningTest():
Test Methods and Test.isRunningTest()
Explains how to use Test.isRunningTest() to modify behavior during test execution.

3. Salesforce Platform Developer II Study Guide:
Covers testing asynchronous Apex, including Queueable jobs, and managing test execution.

The head of recruiting at Universal Containers (UC) wants to provide all internal users the ability to search for open positions by role, department, and location via a new recruiting app. In addition to search, users of the app should be able to refer a friend, apply for a position, and review the status of their current submissions.

The app will be surfaced to UC's existing iOS and Android users via the standard mobile app that Salesforce provides. It has a custom user interface design and offline access is not required. Given these requirements, what is the recommended approach to develop the app?

A. Lightning Experience Builder

B. Salesforce SDK

C. Lightning Web Components

D. Visualforce

C.   Lightning Web Components

Explanation:

To address Universal Containers’ requirement for a recruiting app that allows internal users to search for open positions, refer a friend, apply for positions, and review submission statuses, surfaced via the standard Salesforce mobile app for iOS and Android with a custom user interface and no offline access requirement, we need to select the most suitable development approach. The solution must integrate with the Salesforce mobile app, support a custom UI, and align with Salesforce best practices for modern development. Let’s evaluate the options.

❌ A. Lightning Experience Builder
Lightning Experience Builder (also known as Lightning App Builder) is a point-and-click tool for creating Lightning pages, such as record, home, or app pages, primarily for desktop and mobile web interfaces within Salesforce. While it can be used to build custom pages for the Salesforce mobile app, it is limited to configuring layouts and components rather than creating a fully custom UI with complex functionality like search, referral, and application workflows. It’s not designed for building standalone mobile apps or highly customized interfaces, making it less suitable for the requirement of a custom UI within the Salesforce mobile app.
➥ Reference: Salesforce Help - Lightning App Builder.

❌ B. Salesforce SDK
The Salesforce SDK (specifically, the Salesforce Mobile SDK) is a set of tools and libraries for building custom mobile applications that integrate with Salesforce, available for iOS and Android. It supports creating native, hybrid, or web-based mobile apps with custom UIs and can leverage Salesforce data via APIs (e.g., REST API). Since the app must be surfaced through the standard Salesforce mobile app (not a standalone app), the Mobile SDK is not the best fit, as it is typically used for custom mobile apps rather than extending the Salesforce mobile app’s interface. The SDK could be used for custom mobile development, but it’s overkill for a solution integrated within the existing Salesforce mobile app.
➥ Reference: Salesforce Mobile SDK Development Guide - Overview.

✅ C. Lightning Web Components
Lightning Web Components (LWC) is Salesforce’s modern framework for building reusable, performant UI components using web standards. LWCs can be used to create custom user interfaces and are fully supported in the Salesforce mobile app, which renders Lightning components natively. For the recruiting app, LWCs can implement the required functionality (search by role/department/location, refer a friend, apply for positions, and review submission statuses) with a custom UI tailored to the design requirements. LWCs can be added to Lightning pages via the Lightning App Builder or used in a custom Lightning app, making them ideal for extending the Salesforce mobile app’s interface without requiring offline capabilities. This approach aligns with Salesforce’s modern development model and is recommended for custom UI development.
➥ Reference: Salesforce LWC Developer Guide - Lightning Web Components.

❌ D. Visualforce
Visualforce is Salesforce’s legacy framework for building custom user interfaces using a tag-based markup language and Apex controllers. While Visualforce pages can be accessed in the Salesforce mobile app, they are not optimized for mobile experiences and lack the performance and modern web standards of LWCs. Visualforce is less flexible for creating responsive, custom UIs compared to LWCs, and Salesforce recommends LWCs for new development due to better performance and mobile compatibility. Given the custom UI requirement and the preference for modern development, Visualforce is not the best choice.
➥ Reference: Salesforce Visualforce Developer Guide - Overview.

✅ Correct Answer: C. Lightning Web Components
Reason: Lightning Web Components (LWC) is the recommended approach for developing a recruiting app with a custom user interface that integrates with the Salesforce mobile app. LWCs provide a modern, standards-based framework for building performant, reusable components that can implement the required functionality (search, referral, application, and status review) while supporting a custom UI design. They are fully compatible with the Salesforce mobile app, which renders Lightning components natively, ensuring a seamless user experience on iOS and Android. Since offline access is not required, LWCs meet all requirements efficiently. This aligns with the Salesforce Platform Developer II exam’s emphasis on “User Interface” and modern development practices using LWCs over legacy options like Visualforce.

ℹ️ Additional Notes:
To implement this, the developer would create LWC components for each feature (e.g., a search component, a referral form, an application form, and a status dashboard) and expose them via the Lightning App Builder or a custom Lightning app. The components can use Apex for complex backend logic (e.g., searching records) and Lightning Data Service or @wire adapters for efficient data access. The custom UI can be styled using Salesforce Lightning Design System (SLDS) to ensure consistency with the Salesforce mobile app’s look and feel.

Universal Containers stores user preferences in a Hierarchy Custom Setting, User_Prefs_c, with a Checkbox field, Show_Help_c. Company-level defaults are stored at the organizational level, but may be overridden at the user level. If a user has not overridden preferences, then the defaults should be used. How should the Show_Help_c preference be retrieved for the current user?

A. Boolean show = User_Prefs__c.getValues(UserInfo.getUserId()).Show_Help__c;

B. Boolean show = User_Prefs__c.getInstance().Show_Help__c;

C. Boolean show = User_Prefs__c.Show_Help__c;

D. Boolean show = User_Prefs__c.getValues().Show_Help__c;

B.   Boolean show = User_Prefs__c.getInstance().Show_Help__c;

Explanation:

This question tests understanding of Hierarchy Custom Settings in Salesforce, which allow for:

➳ Org-wide defaults (set at the organization level), and
➳ User-specific overrides (set per user).

When using the method CustomSetting__c.getInstance(), Salesforce automatically checks for a user-level setting, and falls back to the organization-level default if none is found.

✅ Why Option B is correct:

Boolean show = User_Prefs__c.getInstance().Show_Help__c;
✔ This is the standard and recommended way to retrieve a value from a Hierarchy Custom Setting.

✔ It automatically resolves:
→ If user-level data exists → returns it.
→ Else → falls back to org-level default.

❌ Why the other options are incorrect:

A.
Boolean show = User_Prefs__c.getValues(UserInfo.getUserId()).Show_Help__c;
→ This only checks user-level values.
→ If no user-specific record exists, it returns null, not the org default — which violates the requirement.

C.
Boolean show = User_Prefs__c.Show_Help__c;
→ Invalid syntax — this assumes the setting is a static class or field, which it is not.

D.
Boolean show = User_Prefs__c.getValues().Show_Help__c;
→ This only returns org-level default — it ignores user-level overrides, so it's incorrect for this use case.

Reference:
Salesforce Docs – Custom Settings: Hierarchy and Usage

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.