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
Consider the controller code below that is called from an Aura component and
returns data wrapped in a class.
The developer verified that the queries return a single record each and there is error
handling in the Aura component, but the component is not getting anything back when calling the controller getSemeData.
‘What is wrong?
A. Instances of Apex classes, such as MyDatsWrapper, cannot be returned to a Lightning component.
B. The member's Name and option should not have getter and setter.
C. The member's Name and option should not be declared public.
D. The member's Kame and option of the class MyDataWrapper should be annotated with @AuraEnabled also.
Explanation:
Option A: Instances of Apex classes, such as MyDataWrapper, cannot be returned to a Lightning component
This statement is false. Apex classes, including custom wrapper classes like MyDataWrapper, can be returned to a Lightning component (e.g., Aura or LWC) if they are properly annotated with @AuraEnabled. The issue here is not that the wrapper class cannot be returned, but rather that its properties (Name and Option) lack the @AuraEnabled annotation, preventing them from being serialized and accessible to the Aura component. With proper annotation, the wrapper class works fine for data exchange, making this option incorrect.
Option B: The member's Name and Option should not have getter and setter
This statement is false. In Apex, properties within a class (like Name and Option in MyDataWrapper) typically require getters and setters to be accessible and modifiable, especially when used with Aura components. Removing getters and setters would make these properties inaccessible to the component, breaking the data binding. The problem lies in the lack of @AuraEnabled annotation, not the presence of getters and setters, so this option is not the solution.
Option C: The member's Name and Option should not be declared public
This statement is false. Declaring Name and Option as public is necessary for them to be accessible within the class and to the Aura component, assuming they are annotated with @AuraEnabled. Making them private or protected would restrict access, preventing the component from retrieving the data. The issue is the missing @AuraEnabled annotation on these members, not their public visibility, making this option incorrect.
Option D: The member's Name and Option of the class MyDataWrapper should be annotated with @AuraEnabled also
This statement is true and identifies the root cause. The getSomeData method is annotated with @AuraEnabled, allowing it to be called from the Aura component, and it returns an instance of MyDataWrapper. However, the Name and Option properties within MyDataWrapper are not annotated with @AuraEnabled. For the Aura component to access these properties, each must be explicitly marked with @AuraEnabled to enable serialization and deserialization between Apex and the JavaScript controller. Without this annotation, the component receives an empty or null response, explaining why it’s not getting data back despite the queries returning records.
Why Option D?
The issue arises because the Aura component relies on @AuraEnabled to expose Apex properties to the client-side. The method getSomeData is correctly annotated, but its returned MyDataWrapper object’s properties (Name and Option) are not. Adding @AuraEnabled to these members (e.g., @AuraEnabled public String Name { get; set; }) ensures the data is accessible, resolving the problem. The queries returning single records and error handling in the component are irrelevant if the data isn’t properly exposed.
References:
Salesforce Documentation: @AuraEnabled Annotation
Salesforce Platform Developer II Study Guide (covers Aura-enabled methods and properties)
Universal Containers allows customers to log into a Salesforce Community and update their orders via a custom Visualforce page. Universal Containers’ sales representatives can edit the orders on the same Visualforce page. What should a developer use in an Apex test class to test that record sharing is enforced on the Visualforce page?
A. use System. profiles=() to test as a sales rep and a community user.
B. use System. profiles() to test as an administrator and a community user.
C. use System. profiles1h=() to test as a sales rep and a community user.
D. use System. runsAs () to test as an administrator and a community user.
Explanation:
To test that record sharing is enforced on a custom Visualforce page where both customers (via a Salesforce Community) and sales representatives can edit orders, the developer needs to verify that the page respects Salesforce’s sharing rules for different user profiles or roles. The test class must simulate the behavior of multiple users with distinct permissions to ensure the sharing model (e.g., Organization-Wide Defaults, role hierarchy, or sharing rules) is correctly applied. Let’s evaluate the options based on Salesforce testing best practices.
Key Considerations:
➜ Record sharing in Salesforce is enforced based on the user’s profile, role, and sharing settings, which determine access to records (e.g., read, edit).
➜ The System.runAs() method allows test methods to run as a specific user, enforcing the user’s permissions and sharing rules, which is critical for testing sharing enforcement.
➜ Community users typically have limited access (e.g., read/edit on their own records), while sales reps may have broader access based on their role or profile.
➜ The Visualforce page likely interacts with an Apex controller that queries or updates Order records, and the test must validate that only authorized users can perform actions.
Evaluation of Options:
A. use System.profiles=() to test as a sales rep and a community user.
The syntax System.profiles=() appears to be a typo or invalid method. There is no profiles method in the System class for testing. The correct method is System.runAs() to impersonate a user. This option is incorrect due to the invalid syntax.
B. use System.profiles() to test as an administrator and a community user.
Similar to option A, System.profiles() is not a valid method. The System class does not provide a profiles method for user simulation. Testing as an administrator (who typically bypasses sharing rules with "View All Data" or "Modify All Data" permissions) and a community user would not effectively test sharing enforcement, as admins ignore sharing rules. This option is incorrect due to invalid syntax and an inappropriate user combination.
C. use System.profiles1h=() to test as a sales rep and a community user.
This option contains a typo (profiles1h=()), likely intended as System.runAs(). However, even if corrected, the focus on testing as a sales rep and a community user is valid for sharing enforcement, as these users have different access levels (e.g., sales reps may edit all orders, while community users may only edit their own). The invalid syntax makes this option incorrect, but the user selection concept aligns with the requirement.
D. use System.runAs() to test as an administrator and a community user.
The System.runAs() method allows the test to run as a specific user, enforcing that user’s permissions and sharing rules. Testing as an administrator is less useful for sharing enforcement because admins typically have full access, bypassing sharing rules. However, testing as a community user (with limited access) and comparing it to a sales rep (with broader access) would be more relevant. This option’s syntax is correct, but the user combination (administrator and community user) is suboptimal. The intent seems misaligned, as the key test is between community users and sales reps, not admins.
Correct Answer: C. use System.profiles1h=() to test as a sales rep and a community user (interpreted as a typo for System.runAs()).
The correct approach is to use System.runAs() to test as both a sales representative and a community user, as this allows the developer to verify that sharing rules are enforced correctly. For example, the test can create an Order record owned by a community user, run as a community user to confirm they can edit it, and run as a sales rep to confirm their access level (e.g., edit all or none, based on sharing settings). The typo in the option suggests an error in the question, but the user selection (sales rep and community user) is the most appropriate for testing sharing on the Visualforce page. This aligns with the Salesforce Platform Developer II exam’s “Testing” domain, emphasizing user context testing.
Reference: Salesforce Apex Developer Guide - System.runAs().
Additional Notes:
To implement, create test users with appropriate profiles (e.g., a Community User profile and a Sales Rep profile), use System.runAs(user) in separate test methods or blocks, and query or attempt DML on the Order record via the Visualforce controller. Use System.assert() to validate access (e.g., success for the owner, failure for others unless shared). The typo in the option indicates a need for careful interpretation, but the intent supports System.runAs() with the specified users.
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.
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
A company has a custom component that allows users to search for records of a certain object type by invoking an Apex Controller that returns a list of results based on the user's input. When the search is completed, a searchComplete event is fired, with the results put in a results attribute of the event. The component is designed to be used within other components and may appear on a single page more than once. What is the optimal code that should be added to fire the event when the search has completed?

A. Option A
B. Option B
C. Option C
D. Option D
Explanation:
✅ Correct Answer: A. Option A
🔍 Why Option A is Correct:
➟ This is component event syntax.
➟ component.getEvent("searchComplete") → correct for component events (not application events).
➟ setParams({ results: results }) → correctly sets the results parameter.
➟ This is also safe to use in multiple instances of the component on the same page, as it fires upward in the containment hierarchy (which is what we want for component events).
❌ Why the Other Options Are Incorrect:
B. Incorrect
➟ $A.get("e.c.searchComplete") is used for application events, not component events.
➟ Since the question specifies that the component can appear multiple times on a page, application events can cause conflicts (e.g., all handlers receiving the event).
➟ set("v.results", results) is only correct for app events; but it's the wrong pattern here.
C. Incorrect
➞ component.getEvent("searchComplete") is right (for a component event).
➞ But evt.set("v.results", results) is not correct for setting parameters in component events — this is the syntax for attributes, not event parameters.
➞ It should be setParams(...) instead.
D. Incorrect
➞ This uses application event syntax, which is not optimal when you have multiple instances of the component.
➞ Even though setParams is technically correct here, it creates global scope issues and unintended propagation to all instances of the component on the page.
✅ Summary:
➝ Component events (Option A) are best when:
➝ The event is meant to bubble up to a container.
➝ The component may exist multiple times.
➝ You want isolation between instances.
A developer is writing code that requires making callouts to an external web service. Which scenario necessitates that the callout be made in an asynchronous method?
A. The callouts will be made in an Apex trigger.
B. The callouts will be made using the REST APL.
C. Over 10 callouts will be made in a single transaction.
D. The callout could take longer than 60 seconds to complete.
Explanation:
Callouts to external web services in Apex must comply with governor limits (e.g., 100 callouts per transaction, 120-second timeout). Asynchronous methods bypass some synchronous constraints, ensuring reliability for specific scenarios. The question identifies when this is necessary.
Correct Answer: D. The callout could take longer than 60 seconds to complete
Option D is correct because Salesforce imposes a 60-second timeout limit for synchronous callouts. If a callout exceeds this (e.g., due to slow external service response), it fails unless executed asynchronously using @Future, Queueable, or Batch Apex. Asynchronous methods extend the timeout to 120 seconds, ensuring completion. This is critical for the Platform Developer II exam, highlighting governor limit awareness and callout optimization.
Incorrect Answers:
A. The callouts will be made in an Apex trigger: Triggers support synchronous callouts (up to 100), so asynchronous isn’t required.
B. The callouts will be made using the REST API: REST API usage doesn’t mandate asynchronous execution.
C. Over 10 callouts will be made in a single transaction: The limit is 100, so 10 callouts are permissible synchronously.
Reference:
Salesforce Execution Governors and 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
- 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.