Salesforce PDII Online Practice
Questions and Exam Preparation
PDII Exam Details
Exam Code
:PDII
Exam Name
:Salesforce Certified Platform Developer II (Plat-Dev-301)
Certification
:Salesforce Certifications
Vendor
:Salesforce
Total Questions
:445 Q&As
Last Updated
:Jun 19, 2026
Salesforce PDII Online Questions &
Answers
Question 311:
Consider the following code snippet:
public with sharing class AccountsController { @AuraEnabled public List<Account> getAllAccounts() { return [SELECT Id, Name, Industry FROM Account];
}
}
As part of the deployment cycle, a developer creates the following test class:
@IsTest private class AccountsController_Test {
@TestSetup private static void makeData() { User user1 = [ SELECT Id FROM User WHERE Profile.Name = 'System Administrator' LIMIT 1 ];
User user2 = [ SELECT Id FROM User WHERE Profile.Name = 'Standard User' LIMIT 1 ];
TestUtils.insertAccounts(10, user1.Id);
TestUtils.insertAccounts(20, user2.Id);
}
@IsTest private static void testGetAllAccounts() { // Query the Standard User into memory List<Account> result = AccountsController.getAllAccounts();
System.assertEquals(20, result.size());
}
}
When the test class runs, the assertion fails. Which change should the developer implement in the Apex test method to ensure the test method executes successfully?
A. Add @IsTest(seeAllData=true) to line 12 and enclose lines 15 and 16 within Test.startTest() and Test.stopTest(). B. Add System.runAs(user) to line 14 and enclose line 15 within Test.startTest() and Test.stopTest(). C. Query the Standard User into memory and enclose lines 15 and 16 within the System.runAs(user) method. D. Query the Administrator user into memory and enclose lines 15 and 16 within the System.runAs(user) method.
D. Query the Administrator user into memory and enclose lines 15 and 16 within the System.runAs(user) method.
Explanation
The failure of the assertion is caused by the with sharing keyword used in the AccountsController class and the context in which the test is running. The with sharing keyword enforces the sharing rules of the current user. In a test context, the code defaults to running as a System Administrator unless otherwise specified.
In the @TestSetup method, the developer created 10 accounts owned by a System Administrator (user1) and 20 accounts owned by a Standard User (user2). When AccountsController.getAllAccounts() is called without a specific user context, it runs as the administrator and returns all 30 records. The assertion expects exactly 20 records, which corresponds to the number of records owned by the Standard User.
To make the test pass, the developer must execute the method within the context of the Standard User. By querying the Standard User and using System.runAs(user) (Option C), the sharing rules are enforced according to that user's perspective. Under with sharing, the Standard User will only see the 20 Account records they own, assuming private organization-wide defaults and no additional sharing rules. Option A is incorrect because seeAllData=true bypasses test isolation. Option D would still result in an incorrect record count and fail the assertion.
Question 312:
A developer recently released functionality to production that performs complex commission calculations in Apex code called from an Opportunity trigger. Users report that the calculations seem incorrect because the values they see for commissions are wrong.
The developer has representative test data and passing test methods in their developer sandbox.
Which three tools or techniques should the developer use to execute the code and pause it at key lines to visually inspect values of various Apex variables? (Choose Three)
A. Apex Interactive Debugger B. Developer Console C. Breakpoints D. Apex Replay Debugger E. Workbench
A. Apex Interactive Debugger C. Breakpoints D. Apex Replay Debugger
Explanation
To perform traditional "step-through" debugging in Salesforce--where you can pause execution and inspect the state of variables in real-time or near-real-time--developers use the Salesforce extensions for VS Code.
The Apex Replay Debugger (Option D) is a free tool that allows developers to "replay" a transaction using a debug log. By setting Breakpoints (Option C) in their code and then executing the logic (or running a test), the developer can generate a log file. The Replay Debugger then parses this log, allowing the developer to step through the code line-by-line in VS Code as if it were happening live.
The Apex Interactive Debugger (Option A) is a specialized tool (typically requiring a paid add-on for sandboxes) that allows for live, real-time debugging on a sandbox or scratch org. Unlike the Replay Debugger, it pauses the actual execution on the Salesforce server, giving the developer a live view of the environment.
The Developer Console (Option B) and Workbench (Option E) provide log viewing and query capabilities, but they do not support the ability to "pause" execution at specific lines for visual inspection in the manner of a traditional IDE debugger. Therefore, the combination of a debugger tool and the use of breakpoints is the standard requirement for this debugging pattern.
Question 313:
What is the correct order of execution for Visualforce Page "postback" requests (when user interaction requires a page update)?
A. 1) Decode View State2) Evaluate expressions and method calls for the main page and custom components3) Upon successful completion, Evaluate the action that triggered the postback4) Upon successful completion, Update data and redirect user/update view state5) HTML sent to browser B. 1) Evaluate expressions and method calls for the main page and custom components2) Decode View State3) Upon successful completion, Update data and redirect user/update view state4) Upon successful completion, Evaluate the action that triggered the postback5) HTML sent to browser C. 1) Decode View State2) Evaluate expressions and method calls for the main page and custom components3) Upon successful completion, Update data and redirect user/update view state4) Upon successful completion, Evaluate the action that triggered the postback5) HTML sent to browser
A. 1) Decode View State2) Evaluate expressions and method calls for the main page and custom components3) Upon successful completion, Evaluate the action that triggered the postback4) Upon successful completion, Update data and redirect user/update view state5) HTML sent to browser
Question 314:
Which of the following standard fields are indexed? (Choose three.)
A. Name B. CreatedBy C. SystemModStamp D. LastModifedDdate E. RecordType
A. Name B. CreatedBy C. SystemModStamp
Question 315:
Refer to the code below:
When the code runs, it results In a System Limit Exception with the error message: Apex heap size too large.
What should be done to fix this error?
A. Use a SOQL for loop to process the data. B. Convert the Lis: into a 5tc. C. Use Limits.getLimitHeapSize(). D. Use a try/catch block to catch the error.
C. Use Limits.getLimitHeapSize().
Question 316:
If you wanted to create a record following the update of another (with data from the source object), what is the most customizable approach?
A. Workflow Rule B. Process Builder C. After update Trigger D. Flow
B. Process Builder
Question 317:
Where in a query can you use Geolocation and Distance? (Choose two.)
A. Select clause B. Filter clause C. Order By clause D. Group By clause
B. Filter clause C. Order By clause
Question 318:
A developer created a class that implement he Queueable interface, as follows:
public class without sharing OrderQueueableJob implements Queueable {
public void execute(QueueableContext context) { // implementation logic
System.enqueueJob(new FollowUpJob());
}
}
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 Two)
A. Ensure the running user of the test class has, at least, the View All permission on the Order object B. Enclose System.enqueueJob (new orderQueueable Job ( }) within Test. starttest and Test, stoptest () C. Implement seeAllData-true to ensure the Queueable )ob is able to run in bulk mode. D. Implement Test.isRunningtest ( ) to prevent chaining jobs during test execution.
B. Enclose System.enqueueJob (new orderQueueable Job ( }) within Test. starttest and Test, stoptest () D. Implement Test.isRunningtest ( ) to prevent chaining jobs during test execution.
Explanation
Testing asynchronous Apex, such as the Queueable interface, requires specific handling to ensure the job actually executes during the test run and adheres to platform limits.
First, Salesforce enforces a strict limit on chaining Queueable jobs during unit tests. Specifically, you cannot chain jobs (enqueue a job from another job) within a test. Since the OrderQueueableJob attempts to enqueue FollowUpJob, the test will throw an error. To resolve this, the developer should use Test.isRunningTest() (Option D) within the execute method to conditionally bypass the System.enqueueJob call during test runs.
Second, asynchronous jobs are queued by the system and do not run immediately. To force the execution of a Queueable job so that results can be asserted, the System.enqueueJob call must be wrapped within Test. startTest() and Test.stopTest() (Option B) . When Test.stopTest() is called, the execution pauses until all queued asynchronous jobs in that block finish running.
Option C is incorrect because seeAllData does not affect asynchronous processing modes. Option A is incorrect because the class is defined as without sharing, meaning it bypasses sharing rules regardless of the running user's permissions. By combining recursion/chaining guards and the startTest/stopTest block, the developer can reliably test the logic within the execute method.
Question 319:
A developer implemented a custom data table in a Lightning web component with filter functionality. However, users are submitted support tickets about long load times when the filters are changed. The component uses an Apex method that is called to query for records the selected filters.
What should the developer do to improve performance of the component?
A. Use setStorable() in the Apex method to store the response in the client-side cache B. Return all records into a list when the component is created and filter the array in JavaScript C. Use SOSL to Query the records on filter change. D. Use a selective SOQL query with a custom index.
D. Use a selective SOQL query with a custom index.
Explanation
When a data table experiences slow performance during filtering, the root cause is often "non-selective" queries that result in full table scans. In Salesforce, a query is selective when it uses an indexed field in the WHERE clause and filters down to a small percentage of the total records (typically 10% of the first million).
Option D is the correct strategy. By ensuring that the filter fields (such as a Status or Category) are either standard indexed fields or custom fields marked as "External ID" or "Unique" (which creates a custom index), the Query Optimizer can quickly locate the relevant rows. This significantly reduces the database processing time and the "Time to First Byte" (TTFB) returned to the Lightning component.
Option B might seem attractive for small datasets, but it is not scalable; if the org has 50,000 records, returning all of them to the client will crash the browser's heap memory.
Option A (setStorable) is an Aura- specific concept and is replaced by @AuraEnabled(cacheable=true) in LWC, but even caching doesn't help if the initial query itself is slow.
Option C (SOSL) is for text searching across multiple objects and is generally less efficient than a targeted SOQL query for specific field filtering. Using a selective SOQL query ensures the component remains fast as data volume grows.
Question 320:
A developer is building a Lightning web component to get data from an Apex method called getData that takes a parameter, name. The data should be retrieved when the user clicks the Load Data button.
Exhibit.
import { LightningElement } from 'lwc';
import getData from '@salesforce/apex/AccountInfo.getData';
export default class AccountInfo extends LightningElement { account;
A. Add @wire(getData, { name: '$name' }) to the account field and add this.account = getData(); to the loadData() function. B. Add this.account = getData(this.name); to the loadData() function. C. Add getData({ name: this.name }).then(result => { this.account = result; }); to the loadData() function. D. Add @wire(getData, { name: '$name' }) to the account field and delete loadData() because it is not needed.
C. Add getData({ name: this.name }).then(result => { this.account = result; }); to the loadData() function.
Nowadays, the certification exams become more and more important and required by more and more
enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare
for the exam in a short time with less efforts? How to get a ideal result and how to find the
most reliable resources? Here on Vcedump.com, you will find all the answers.
Vcedump.com provide not only Salesforce exam questions,
answers and explanations but also complete assistance on your exam preparation and certification
application. If you are confused on your PDII exam preparations
and Salesforce certification application, do not hesitate to visit our
Vcedump.com to find your solutions here.