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 2026

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

22024 already prepared
Salesforce 2026 Release
202 Questions
4.9/5.0

An Apex trigger creates an order co record every time an Opportunity is won by a Sales Rep. Recently the trigger is creating two orders. What is the optimal technique for 2 developer to troubleshoot this?

A. Disable all flows, and then re-enable them one at at time to see which one causes the error.

B. Run the Apex Test Classes for the Apex trigger to ensure the code still has sufficient code coverage.

C. Set up debug logging for every Sales Rep, then monitor the logs for errors and exceptions,

D. Add system.debug() statements to the code and use the Developer Console logs to trace the code.

D.   Add system.debug() statements to the code and use the Developer Console logs to trace the code.

Explanation:

đź§  Scenario Overview:
A trigger is unintentionally creating two Order records instead of one when an Opportunity is marked as Closed Won. This could be caused by:
➡️ Trigger recursion
➡️ Duplicate logic in Flows + Apex
➡️ Improper use of static variables
➡️ Automation running multiple times (Flows, PB, Apex, etc.)
To fix this, a developer must trace exactly what code paths are executing and when duplicate logic is triggered.

âś… Why D is Correct (System.debug + Developer Console):
âś” Adding System.debug() statements gives granular, line-by-line visibility of how the trigger is executing.
âś” The Developer Console logs allow devs to trace trigger execution, DML statements, and potential recursion or duplicate logic paths.
✔ You can confirm where the second Order is created, and whether it’s coming from a trigger, flow, or Apex method.
âś” Most efficient and developer-friendly way to pinpoint logic bugs or recursive execution.

❌ Why Other Options Are Incorrect:

A. Disable all flows and re-enable one by one:
➯ This is manual and time-consuming.
➯ Disabling all flows can impact unrelated automation.
➯ Doesn't confirm if issue is caused by flows, triggers, or other automation.
➯ Risky in a shared org or production environment.

B. Run Apex test classes:
➯ Running test classes checks coverage and correctness, but won’t expose runtime duplication issues unless tests are specifically written for this scenario.
➯ Doesn’t provide detailed trace of trigger logic during normal use.

C. Set up debug logging for every Sales Rep:
➯ Impractical and excessive — too many logs.
➯ The issue is with trigger logic, not necessarily user-specific behavior.
➯ Hard to manage and monitor logs for each individual user.

📚 Reference:
🔗 Salesforce Developer Guide – Debugging Apex Code
đź”— Understanding Apex Trigger Recursion

Universal Containers decided to use Salesforce to manage a new hire interview process. A custom object called Candidate was created with organization-wide defaults set to Private. A lookup on the Candidate object sets an employee as an Interviewer. What should be used to automatically give Read access to the record when the lookup field is set to the Interviewer user?

A. The record can be shared using an Apex class.

B. The record can be shared using a permission set.

C. The record can be shared using a sharing rule.

D. The record cannot he shared with the current setup

C.   The record can be shared using a sharing rule.

Explanation:

Universal Containers has set the organization-wide defaults (OWD) for the custom Candidate object to Private, meaning only the record owner and users with higher access (e.g., via roles, sharing rules, or manual sharing) can view the records. A lookup field on the Candidate object links to an Employee (assumed to be a User record) as an Interviewer. The requirement is to automatically grant Read access to the Candidate record when the Interviewer lookup field is set to a specific user. Let’s evaluate the options:

Option A: The record can be shared using an Apex class. While Apex can be used to create sharing records (e.g., via the CandidateShare object for a custom object), this approach requires custom code to detect when the Interviewer lookup field is updated and programmatically insert a sharing record. This is not an automatic, declarative solution and involves manual development, testing, and maintenance. It is less efficient than using built-in Salesforce features like sharing rules.

Option B: The record can be shared using a permission set. Permission sets grant additional permissions to users, such as object-level access (e.g., Read, Create) or field-level access. However, permission sets do not dynamically share individual records based on field values (e.g., the Interviewer lookup). They provide broad access to all records of an object for users assigned the permission set, which does not meet the requirement of automatically sharing a specific Candidate record with the Interviewer user.

Option C: The record can be shared using a sharing rule. Sharing rules are a declarative way to extend access to records based on criteria or ownership. A criteria-based sharing rule can be created for the Candidate object to grant Read access to users specified in the Interviewer lookup field. For example, the rule can be configured to share the record with the user whose ID matches the Interviewer field value whenever it is populated. This automates the sharing process without requiring code, making it the most appropriate solution given the Private OWD and the need for dynamic access.

Option D: The record cannot be shared with the current setup. This is incorrect because Salesforce provides mechanisms like sharing rules to extend access beyond the Private OWD. The lookup field to the Interviewer (User) allows for criteria-based sharing, enabling automatic Read access when the field is set.

Why Option C is Best:
With OWD set to Private, sharing rules are the standard Salesforce feature to automatically grant access to records based on field values or other criteria. A criteria-based sharing rule can evaluate the Interviewer lookup field and share the Candidate record with that user, ensuring Read access is granted dynamically. This aligns with Salesforce’s security model and avoids the complexity of custom Apex code.

Implementation Notes:
Create a criteria-based sharing rule on the Candidate object.
Set the criteria to match records where the Interviewer field is not null.
Grant Read access to the users specified in the Interviewer field.
Ensure the rule is active and tested to confirm access is applied correctly.

References:
1. Salesforce Documentation - Sharing Rules:
Explains how to use criteria-based sharing rules to extend access based on field values.

2. Salesforce Documentation - Organization-Wide Defaults:
Details how OWD interacts with sharing rules to control record access.

3. Salesforce Platform Developer II Study Guide:
Covers security and sharing models, including the use of sharing rules for dynamic access control.

Given the following code:

Assuming there were 10 Contacts and five Accounts created today, what is the expected result?

A. System.QueryException: Too many DML Statement errors on Contact

B. System.QueryException: List has more than one row for Assignment on Account

C. Systemn.LimitException: Too many SOQL Queries on Account

D. System.LimitException: Too many SOQL Queries on Contact

B.   System.QueryException: List has more than one row for Assignment on Account

Explanation:

🔍 Code Breakdown

for (Contact c : [SELECT Id, LastName FROM Contact WHERE CreatedDate = TODAY]) {
Account a = [SELECT Id, Name FROM Account WHERE CreatedDate = TODAY LIMIT 5];
c.AccountId = a.Id;
update c;
}
âžź The code is looping through Contacts created today.
âžź Inside the loop, it runs a SOQL query on Account with LIMIT 5, then assigns one of those accounts to the Contact.
âžź However, the result of that SOQL is not stored as a list, but in a single Account a.

đź§  Key Concept: SOQL Result Expectation

The line:

➥ Account a = [SELECT Id, Name FROM Account WHERE CreatedDate = TODAY LIMIT 5];

means the query can return up to 5 rows, but Apex is trying to store the result in a single object, not a list.
That’s a problem.

âś… Correct Answer:
B. System.QueryException: List has more than one row for assignment on Account

đź’Ą Why?
When a SOQL query returns more than one record, and you try to assign the result to a single sObject variable, Salesforce throws a QueryException. Specifically:

➥ System.QueryException: List has more than 1 row for assignment to SObject

This happens even if you used LIMIT 5. Since the query returned more than one Account, and you're trying to assign that list of Accounts to a single Account variable, it crashes.

🧪 Let’s confirm:
10 contacts = âś… Loop will run 10 times.
5 accounts = âś… SOQL will return 5 rows each time.
Account a = [...] = ❌ Can't assign 5 rows to a single Account.

Which interface needs to be implemented by an Aura component so that it may be displayed in modal dialog by clicking a button on a Lightning record page?

A. farce:lightningEditRAation

B. lightning:editiction

C. force:lightningQuickhction

D. lightning:quickAction

D.   lightning:quickAction

Explanation:

To determine which interface needs to be implemented by an Aura component to be displayed in a modal dialog when a button is clicked on a Lightning record page, we need to consider Salesforce's Lightning framework and its support for quick actions. A quick action on a Lightning record page can open a modal dialog to perform custom operations, and certain interfaces enable Aura components to be invoked in this manner. Let's evaluate each option based on Salesforce documentation and best practices.

Correct Answer: D. lightning:quickAction
Option D, lightning:quickAction, is the correct interface to implement for an Aura component to be displayed in a modal dialog when triggered by a button on a Lightning record page. This interface allows the component to be used as a custom quick action, which Salesforce renders in a modal popup. By implementing lightning:quickAction, the component can access the record context and interact with the page, making it suitable for tasks like data entry or custom logic. This is a standard practice in Salesforce development, especially for the Platform Developer II exam, where understanding Lightning component integration is key. The interface ensures the component is properly formatted and compatible with the quick action framework.

Incorrect Answer:

Option A: farce:lightningEditAction
Option A, farce:lightningEditAction, appears to be a typographical error or non-existent interface (likely intended as force:lightningEditAction or similar). There is no such interface in the Salesforce Lightning framework. Even if corrected to a similar name, no standard interface like force:lightningEditAction exists for enabling modal dialogs via quick actions. This option does not align with Salesforce's documented interfaces for Aura components, making it invalid for the intended purpose of displaying a component in a modal dialog on a Lightning record page.

Option B: lightning:editAction
Option B, lightning:editAction, is not a recognized interface in the Salesforce Lightning namespace. The lightning namespace includes components and utilities, but no lightning:editAction interface exists for enabling a component to be displayed as a quick action in a modal dialog. This option might be confused with editing-related components or actions, but it lacks the specific functionality required to integrate with quick actions on a Lightning record page. As a result, it is not a viable choice for this scenario.

Option C: force:lightningQuickAction
Option C, force:lightningQuickAction, is not a valid interface in the Salesforce Aura framework. The force namespace includes utilities like force:recordData for record access, but no force:lightningQuickAction interface exists to enable a component as a quick action in a modal dialog. This might be a misinterpretation of the lightning:quickAction interface or related features. Without official support, this option cannot be used to display an Aura component in a modal dialog when a button is clicked on a Lightning record page.

Reference:
Salesforce Lightning Components Basics

Consider the below trigger intended to assign the Account to the manager of the Account's region:

A. Option A

B. Option B

C. Option C

D. Option D

B.   Option B
D.   Option D

Explanation:

❌ Option A: Add if (!accountList.isEmpty()) before updating accountList
Adding a condition like if (!accountList.isEmpty()) before updating accountList is a precautionary step to ensure the list contains records before processing. This practice helps avoid null pointer exceptions or unnecessary operations if the list were unexpectedly empty. In the context of this trigger, accountList is initialized as new List() and populated from trigger.new, which is always non-empty in a before trigger execution. Therefore, this check is technically redundant here since the trigger will not fire without records. While it’s a good habit in scenarios where lists are dynamically built or modified outside the trigger context, it does not address the primary performance or logic concerns, such as the query inside the loop or the unnecessary DML operation. Thus, it’s not a critical change for this specific case, making it less relevant to the best practices focus here.

âś… Option B: Move the Region__c query outside the loop
Moving the Region__c query outside the loop is a crucial best practice to enhance performance and scalability. Currently, the trigger queries Region__c for each Account in trigger.new using anAccount.Region__Name__c, which can lead to multiple SOQL queries and potentially exceed the 100 SOQL query governor limit if more than 100 Accounts are processed. By collecting all unique Region__Name__c values into a Set and performing a single query (e.g., SELECT Name, Region_Manager__c FROM Region__c WHERE Name IN :regionNames), the trigger becomes bulkified. This approach reduces resource usage, avoids governor limit exceptions, and handles bulk operations like Data Loader imports efficiently. It also allows for better error handling, such as managing null Region__Name__c values, making it a fundamental improvement for large datasets and a key reason this option is selected.

❌ Option C: Use a Map to cache the results of the Region__c query by Id
Using a Map to cache the results of the Region__c query by Id is an optimization technique to improve performance by storing query results for quick access. This approach is particularly useful when the same data might be queried multiple times or when relating records by a unique identifier like Id. However, in this trigger, the query is based on Name (from anAccount.Region__Name__c) rather than Id, so caching by Id isn’t directly applicable unless the relationship changes to a lookup field. A Map keyed by Name could be used after moving the query outside the loop, enhancing lookup efficiency. While this is a valuable secondary improvement, it depends on Option B being implemented first and isn’t one of the two most critical changes needed to address the immediate performance and DML issues, thus it’s not selected here.

âś… Option D: Remove the last line that updates accountList because it is not needed
Removing the last line update accountList; is essential because it’s unnecessary in a before trigger context. In before triggers, any modifications to trigger.new—such as setting anAccount.OwnerId—are automatically persisted to the database when the trigger completes, eliminating the need for an explicit DML operation. Keeping this line can lead to runtime errors, such as recursion or constraint violations, and consumes governor limits (e.g., 150 DML statements), though it’s unlikely to hit the limit here. This change simplifies the code, reduces overhead, and aligns with best practices for leveraging the implicit save behavior of before triggers. If the trigger were an after trigger, an update would be required, but given the current design, removing it is a clear improvement, making it a selected option.

Why Options B and D?
Option B addresses the critical performance issue of querying inside a loop, bulkifying the trigger to handle large datasets within governor limits, a core Salesforce best practice. Option D eliminates redundant DML, simplifying the code and preventing potential errors, aligning with efficient trigger design. Together, these changes optimize performance and correctness, ensuring the trigger is robust for production use.

References:
Trigger Best Practices
Governor Limits

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.