Last Updated On : 28-Sep-2026
Salesforce Certified Platform Developer II (SP25) Practice Test
Prepare with our free Salesforce Certified Platform Developer II (SP25) sample questions and pass with confidence. Our Salesforce-Platform-Developer-II practice test is designed to help you succeed on exam day.
Salesforce 2026
The Lightning Component allows users to click a button to save their changes and then redirects them to a different page. Currently, when the user hits the Save button, the records are getting saved, but they are not redirected. Which three techniques can a developer use to debug the JavaScript?
A. Use the browser's dev tools to debug the JavaScript.
B. Use Developer Console to view the debug log.
C. Use console.log() messages in the JavaScript.
D. Use Developer Console to view7 checkpoints.
E. Enable Debug Mode for Lightning components for the user.
C. Use console.log() messages in the JavaScript.
E. Enable Debug Mode for Lightning components for the user.
Explanation:
This question tests debugging strategies specifically tailored for client-side JavaScript execution within the Salesforce Lightning Component framework (Aura and LWC). Because client-side JavaScript executes locally inside the user's web browser rather than on the Salesforce application servers, identifying redirection failures or missing navigation events requires browser-centric tools, client-side logging mechanisms, and unminified source code.
✅ Correct Option:
Option A
Option A utilizes the web browser's built-in developer tools (such as Chrome DevTools or Firefox Developer Tools) to inspect client-side execution. Developers can set active breakpoints within the JavaScript controller or helper files, pause execution when the Save button is clicked, step through navigation code line by line, inspect event payloads, and observe whether redirection events or page navigation services are firing correctly.
Option C
Option C inserts console.log() statements directly inside the client-side JavaScript functions to output debug messages to the browser console. This allows the developer to trace execution flow step-by-step, verify whether callback functions complete successfully post-save, inspect variable states, and confirm if navigation parameters or page references are valid prior to triggering the redirect.
Option E
Option E involves turning on "Debug Mode for Lightning Components" under Salesforce Setup for the active user. By default, Salesforce minifies and optimizes JavaScript code to boost performance in production. Enabling Debug Mode disables client-side minification and provides readable, uncompressed JavaScript source code with detailed framework warning messages, making browser-based debugging significantly easier.
❌ Incorrect options:
Option B
Option B relies on inspecting Apex Debug Logs within the Developer Console, which is ineffective here. Apex Debug Logs exclusively capture server-side database operations, controller method calls, system limits, and Apex code execution. Because client-side JavaScript redirection happens entirely within the user's browser, server-side Apex logs will reveal nothing about browser navigation failures.
Option D
Option D suggests using Apex Checkpoints in the Developer Console. Checkpoints are design-time debugging tools used to capture snapshot memory states, variable values, and heap allocations of server-side Apex execution during runtime. They have no visibility into client-side JavaScript execution, DOM events, or Lightning component navigation mechanisms.
🔧 Reference:
→ Salesforce Developer Documentation: Debug Client-Side Code - Confirms client-side debugging strategies including browser developer tools, console logging, and enabling Lightning Debug Mode for unminified source code.
A developer is trying to decide between creating a Visualforce component or a Lightning component. Which scenario necessitates the use of Visualforce?
A. Does the screen need to be rendered as a PDF without using a third-party application?
B. (Option Not Provided in Context)
C. Will the screen make use of a JavaScript framework?
D. (Matches Option A in context of question logic)
Explanation
The key requirement is identifying a capability that specifically requires Visualforce rather than Lightning components.
Visualforce provides native support for rendering a page as a PDF using Salesforce's built-in PDF rendering capability.
Lightning components are designed for modern, dynamic user interfaces and can use JavaScript frameworks and client-side functionality.
Therefore, using a screen that must be rendered directly as a PDF without an external application points to Visualforce.
The scenario described in Option A is the distinguishing requirement.
Therefore, Option A is correct.
Correct Option
🟢 A. Does the screen need to be rendered as a PDF without using a third-party application?
Visualforce is the appropriate technology when a Salesforce page must be rendered as a PDF using Salesforce's native functionality. A Visualforce page can use the renderAs="pdf" attribute to generate PDF output without requiring a third-party application. Lightning components do not provide an equivalent native page-rendering mechanism for generating PDF output. Therefore, when direct Salesforce PDF rendering is a mandatory requirement, Visualforce is the necessary choice.
Incorrect Options
❌ B. Option not provided in the question.
Because the actual text of Option B is missing, its specific functionality cannot be evaluated. Based on the available choices, there is no information establishing that B requires Visualforce. The documented requirement that clearly distinguishes Visualforce is native PDF rendering.
❌ C. Will the screen make use of a JavaScript framework?
Using JavaScript does not necessitate Visualforce. Lightning components are designed to support client-side JavaScript and can incorporate JavaScript frameworks or libraries where appropriate. Therefore, JavaScript-based functionality is not a Visualforce-specific requirement.
❌ D. Matches Option A in the context of the question logic.
If D is intended to duplicate Option A, it does not represent an independent scenario requiring separate consideration. The distinguishing capability is native PDF rendering through Visualforce. Without additional information defining D as a different requirement, Option A remains the identifiable answer.
Reference
⇒ apex:page — Confirms that Visualforce pages support the renderAs attribute for rendering page content as PDF.
A developer is asked to build a solution that will automatically send an email to the customer when an Opportunity stage changes. The solution must scale to allow for 10,000 emails per day. The criteria to send the email should be evaluated after certain conditions are met. What is the optimal way to accomplish this?
A. Use an Apex trigger with Batch Apex.
B. Use an Email Alert with Flow Builder.
C. Use MassEmailMessage() with an Apex trigger.
D. Use SingleEmailMessage() with an Apex trigger.
Explanation:
This question tests the optimal automation tool for sending automated emails at scale when a record field changes. The requirement is to send 10,000 emails per day when an Opportunity's stage changes, with criteria evaluated after certain conditions are met.
✅ Correct Option:
B. Use an Email Alert with Flow Builder.
A Record-Triggered Flow can monitor Opportunity stage changes and invoke an Email Alert when conditions are satisfied. Email Alerts sent through Flow count against the workflow email limit, which is 1,000 per day per standard Salesforce license and up to 2,000,000 org-wide. For an org with 10 standard licenses, this provides 10,000 emails per day—exactly meeting the requirement. The Flow evaluates criteria after the record is saved, satisfying the "after certain conditions are met" requirement.
❌ Incorrect options:
A. Use an Apex trigger with Batch Apex.
Batch Apex is designed for processing large volumes of records asynchronously, not for real-time email sends triggered by individual record changes. While it can scale, it introduces unnecessary complexity and delay. The requirement is to send emails when stage changes occur, not in scheduled batches.
C. Use MassEmailMessage() with an Apex trigger.
MassEmailMessage sends emails to multiple recipients using templates, limited to 250 recipients per call. Sending 10,000 emails would require 40 separate calls, and Apex email sends count against the 5,000 daily org-wide limit, falling short of 10,000. It also requires complex bulkification and error handling.
D. Use SingleEmailMessage() with an Apex trigger.
SingleEmailMessage sends individual emails, but Apex email is capped at 5,000 single emails per day org-wide—half the required volume. Additionally, only 10 sendEmail() invocations per transaction are allowed, making bulk sends from a trigger prone to governor limit failures.
🔧 Reference:
→ Salesforce Help — Considerations for Using Email Alerts — Confirms that email alerts from workflow, approval, process, and flow share a limit of 1,000 per license per day, with an org-wide cap of 2,000,000.
→ Salesforce Developers — Apex Email Limits — Confirms the 5,000 daily email limit and 10 sendEmail invocations per transaction for Apex-based email sending.
A company wants to track revenue through a related object. They need to perform a onetime seeding of data for roughly 100,000 Opportunities, creating Revenue records based on complex logic. What is the optimal way to automate this?
A. Use Database.executeBatch() to invoke a Database.Batchable class.
B. Use System.enqueueJob() to invoke a Queueable class.
C. Use Database.executeBatch() to invoke a Queueable class.
D. Use System.scheduleJob() to schedule a Database.Scheduleable class.
Explanation:
The requirement is a one-time bulk data-seeding operation that must process approximately 100,000 Opportunity records and create related Revenue records according to complex business logic. Because the volume is large and the logic is non-trivial, the solution must be fully asynchronous, automatically chunk the work, and reset governor limits for each batch of records. Batch Apex is the platform feature purpose-built for exactly this class of long-running, high-volume data-processing jobs.
✅ Correct Option:
✅ A. Use Database.executeBatch() to invoke a Database.Batchable class.
Implement a class that implements the Database.Batchable interface. In the start() method return a QueryLocator (or Iterable) that selects the Opportunities. In the execute() method apply the complex Revenue-creation logic to each scope of records. Optionally perform any final aggregation or notification work in the finish() method. Calling Database.executeBatch() launches the job immediately, processes the records in manageable chunks (default 200, configurable up to 2,000), and gives each execute() invocation a fresh set of governor limits—making it the optimal, scalable approach for a one-time seeding of ~100 k records.
❌ Incorrect options:
❌ B. Use System.enqueueJob() to invoke a Queueable class.
Queueable Apex is ideal for smaller-to-medium workloads, job chaining, and callouts, but a single Queueable job is still bound by the normal asynchronous query-row limit (50,000). Processing 100,000 Opportunities would require manual chaining and careful state management, which is more complex and less efficient than the built-in chunking provided by Batch Apex.
❌ C. Use Database.executeBatch() to invoke a Queueable class.
Database.executeBatch() accepts only classes that implement the Database.Batchable interface. A Queueable class cannot be passed to this method; the combination is syntactically and functionally invalid.
❌ D. Use System.scheduleJob() to schedule a Database.Scheduleable class.
Schedulable Apex is intended for jobs that must run on a recurring schedule or at a future point in time. A pure one-time seeding task does not require scheduling. While a Schedulable class could launch a Batch job, introducing the scheduler adds unnecessary complexity for a job that can (and should) be started immediately with Database.executeBatch().
🔧 Reference:
→ Asynchronous Apex (Apex Developer Guide – Salesforce Developers)
Explicitly recommends Batch Apex “for long-running jobs with large data volumes that need to be performed in batches, such as database maintenance jobs.”
Which code snippet represents the optimal Apex trigger logic for assigning a Lead's Region based on its PostalCode, using a custom Region__c object?
A. Java
Set< String > zips = new Set< String >();
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
zips.add(l.PostalCode);
}
}
List< Region__c > regions = [SELECT Zip_Code__c, Region_Name__c FROM Region__c
WHERE Zip_Code__c IN :zips];
Map< String, String > zipMap = new Map< String, String >();
for(Region__c r : regions) {
zipMap.put(r.Zip_Code__c, r.Region_Name__c);
}
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
B. Region__c = zipMap.get(l.PostalCode);
}
}
C. Java
Set< String > zips = new Set< String >();
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
zips.add(l.PostalCode);
}
}
for (Lead l : Trigger.new) {
List< Region__c > regions = [SELECT Zip_Code__c, Region_Name__c FROM Region__c
WHERE Zip_Code__c IN :zips];
for (Region__c r : regions) {
if(l.PostalCode == r.Zip_Code__c) {
D. Region__c = r.Region_Name__c;
}
}
}
E. Java
for (Lead l : Trigger.new) {
Region__c reg = [SELECT Region_Name__c FROM Region__c WHERE Zip_Code__c =
:l.PostalCode];
F. Region__c = reg.Region_Name__c;
}
G. Java
Set< String > zips = new Set< String >();
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
zips.add(l.PostalCode);
}
}
for(Lead l : Trigger.new) {
List< Region__c > regions = [SELECT Zip_Code__c, Region_Name__c FROM Region__c
WHERE Zip_Code__c IN :zips];
for(Region__c r : regions) {
if(l.PostalCode == r.Zip_Code__c) {
H. Region__c = r.Region_Name__c;
}
}
}
Set< String > zips = new Set< String >();
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
zips.add(l.PostalCode);
}
}
List< Region__c > regions = [SELECT Zip_Code__c, Region_Name__c FROM Region__c
WHERE Zip_Code__c IN :zips];
Map< String, String > zipMap = new Map< String, String >();
for(Region__c r : regions) {
zipMap.put(r.Zip_Code__c, r.Region_Name__c);
}
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
B. Region__c = zipMap.get(l.PostalCode);
}
}
Explanation
The question tests bulkification of Apex triggers, particularly avoiding SOQL queries inside loops.
A trigger must be designed to process multiple Leads in the same transaction.
The postal codes should first be collected into a Set so they can be queried together.
The matching Region__c records should then be retrieved with one SOQL query.
Options C–D, E–F, and G–H place SOQL inside a Lead loop, which can exceed governor limits.
Therefore, A–B is the optimal solution because it performs one query outside the processing loop.
Correct Option
✔️ A–B. Use a Set, one SOQL query, a Map, and direct Map lookup.
This is the optimal implementation because it collects all unique postal codes first, then retrieves all matching Region__c records with a single SOQL query outside the Lead loop. The results are stored in a Map keyed by postal code, allowing each Lead to retrieve its corresponding region efficiently. This pattern is bulkified, avoids repeated database queries, and respects Salesforce governor limits when multiple Leads are processed together.
Incorrect Options
❌ C–D. Query Region__c inside the Lead loop and compare records.
Although the postal codes are collected in a Set, the SOQL query is still inside the Trigger.new loop. Multiple Leads therefore cause repeated queries and can exceed Salesforce's SOQL governor limit. The nested comparison also adds unnecessary processing. The query should execute once outside the Lead loop.
❌ E–F. Query Region__c separately for every Lead.
This is not bulkified because every Lead causes another SOQL query. A bulk transaction containing many Leads can quickly exceed the governor limit. It also repeats database work when multiple Leads have the same postal code. The records should instead be retrieved collectively with one query.
❌ G–H. Query Region__c inside the Lead loop and then compare every Region.
This option combines two inefficient patterns: SOQL is executed inside the Lead loop, and each Lead is compared against every returned Region record. The query can exceed governor limits in bulk transactions, while the nested loops perform unnecessary comparisons. A single query followed by Map-based lookup is more efficient.
Reference
⇒ Apex Bulkification Best Practices — Confirms that SOQL should be placed outside loops and that Sets and Maps are useful for bulkified trigger processing.
⇒ Apex Trigger Best Practices — Confirms the importance of bulkifying SOQL and DML operations in Apex triggers.
| Salesforce-Platform-Developer-II Exam Questions - Home |
| Page 2 out of 33 Pages |