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 21:
A developer is tasked by Universal Containers to build out a system to track the container repair process. Containers should be tracked as they move through the repair process, starting when a customer reports an issue and ending when the container is returned to the customer.
Which solution meets these business requirements while following best practices?
A. Build a mobile application using Platform Events and RFID integration to ensure proper tracking of the containers and keep the customer informed. B. Involve a Salesforce administrator and build out a declarative solution that will be easy to maintain and likely cost less than customized development. C. Build a customized Lightning Application using Application Events to ensure data integrity. D. Develop a new system with automated notification to move the containers through the repair process while notifying the customer that reported the issue.
D. Develop a new system with automated notification to move the containers through the repair process while notifying the customer that reported the issue.
Question 22:
An org has a custom object, Registration__c, that has a lookup relationship to the Opportunity object.
What should a developer use to create a stand-alone Visualforce page that displays the Registration__c records related to an Opportunity?
A. A standard controller with a controller extension B. A controler extension C. A custom controler D. A standard controller
A. A standard controller with a controller extension
Question 23:
The test method above calls a web service that updates an external system with Account information and sets the Account's Integration_Updated__c checkbox to True when it completes. The test fails to execute and exits with an error:
"Methods defined as TestMethod do not support Web service callouts. "
What is the optimal way to fix this?
A. Add if (!Test.isRunningTest()) around CalloutUtil.sendAccountUpdate. B. Add Test.startTest() before and Test.stopTest() after CalloutUtil.sendAccountUpdate. C. Add Test.startTest() before and Test.setMock and Test.stopTest() after CalloutUtil.sendAccountUpdate. D. Add Test.startTest() and Test.setMock before and Test.stopTest() after CalloutUtil.sendAccountUpdate.
D. Add Test.startTest() and Test.setMock before and Test.stopTest() after CalloutUtil.sendAccountUpdate.
Explanation
Salesforce enforces a strict restriction: actual network callouts are prohibited during unit tests. This is to ensure that tests are deterministic, fast, and do not rely on the availability or state of external third-party systems. When the testing engine encounters a System.Http.send() or a web service call without a mock, it throws the error:
"Methods defined as TestMethod do not support Web service callouts."
To resolve this, the developer must provide a mock implementation. By using Test.setMock() (Option D), the developer instructs the Apex runtime to intercept any callouts and return a predefined response instead of attempting a real connection. The mock class must implement either the HttpCalloutMock interface (for REST) or the WebServiceMock interface (for SOAP).
Furthermore, the call to the mock and the callout method should be wrapped in Test.startTest() and Test.stopTest().
Test.startTest(): Resets governor limits, providing a fresh context for the specific logic being tested.
Test.stopTest(): Forces any asynchronous processing (often used in callouts, such as @future or Queueable) to complete before the next line of code executes.
In the provided code, Test.setMock() must be called before CalloutUtil.sendAccountUpdate for the platform to know which mock to use. Once Test.stopTest() is reached, the mock response is processed, the checkbox is updated, and the subsequent SOQL query and assertion will correctly see the updated data. Option A is a poor practice because it skips the logic entirely, resulting in 0% code coverage for the integration logic.
Question 24:
A developer wrote a class named AccountHistoryManager that relies on field history tracking. The class has a static method called getAccountHistory that takes in an Account as a parameter and returns a list of associated AccountHistory object records.
The following test fails:
What should be done to make this test pass?
A. Use Test.isRunningTest() in getAccountHistory() to conditionally return fake AccountHistory records. B. Use @isTest (SeeAllData=true) to see historical data from the org and query for AccountHistory records. C. Create AccountHistory records manually in the test setup and write a query to get them. D. The test method should be deleted since this code cannot be tested.
B. Use @isTest (SeeAllData=true) to see historical data from the org and query for AccountHistory records.
Explanation
A significant challenge in Salesforce unit testing is that system-generated records, such as those in the AccountHistory or OpportunityHistory objects, are not created during the execution of a test method, even if field history tracking is enabled in the organization. Because these records are read-only and managed by the system, a developer cannot manually insert them via DML within a test setup. Consequently, the query in the getAccountHistory method will always return an empty list in a test context, causing the System.assert to fail.
The optimal programmatic solution to this limitation is to implement a "mocking" strategy using Test. isRunningTest(). By modifying the production code within getAccountHistory, the developer can check if the code is currently being executed by a unit test. If it is, the method can return a manually constructed list of AccountHistory records (stored in memory but not inserted into the database) to satisfy the test's requirements. This allows the test to verify the logic that processes the history data without needing the system to actually generate historical records. While SeeAllData=true (Option B) would allow the test to see real data in the org, it is considered a poor practice because it makes the test dependent on the specific state of the organization's data, leading to brittle tests that may fail in different environments.
Question 25:
Refer to the code snippet below:
As part of an integration development effort, a developer is tasked to create an Apex method that solely relies on the use of foreign identifiers in order to relate new contact records to existing Accounts in Salesforce. The account object contains a field marked as an external ID, the API Name of this field is Legacy_Id_c.
What is the most efficient way to instantiate the parentAccount variable on line 02 to ensure the newly created contact is properly related to the Account?
A. Account parentAccount = new Account(Legacy_Id_c = externalIdentifier); B. Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier].Id; C. Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier]; D. Account parentAccount = new Account();parentAccount.Id = externalIdentifier;
A. Account parentAccount = new Account(Legacy_Id_c = externalIdentifier);
Question 26:
Universal Containers is leading a development team that follows the source-driven development approach in Salesforce. As part of their continuous integration and delivery (CI/CD) process, they need to automatically deploy changes to multiple environments, including sandbox and production.
Which mechanism or tool would best support their CI/CD pipeline in source-driven development?
A. Salesforce CLI with Salesforce DX B. Change Sets C. Salesforce Extensions for Visual Studio Code D. Ant Migration Tool
A. Salesforce CLI with Salesforce DX
Explanation
Source-driven development shifts the "source of truth" from the Salesforce org to a version control system (like Git). Salesforce DX (Developer Experience) was specifically designed to support this paradigm by introducing the Salesforce CLI (Command Line Interface). The Salesforce CLI is the primary engine for modern CI/CD pipelines because it allows for the scripted creation of scratch orgs, automated testing, and the deployment of source code to any environment (sandboxes, scratch orgs, or production) using simple command-line instructions.
Unlike traditional tools, the Salesforce CLI supports the "source" format, which is more granular and easier to manage in version control than the traditional metadata format used by the Ant Migration Tool. Change Sets (Option B) are manual, UI-driven tools that cannot be automated in a CI/CD pipeline and are strictly org-to-org. Salesforce Extensions for Visual Studio Code (Option C) provide a powerful IDE interface for developers, but the extensions themselves rely on the underlying Salesforce CLI to perform deployments; they are not the automation tool used by the pipeline itself. The Ant Migration Tool (Option D) is an older technology that uses the Metadata API and is generally considered legacy compared to the more flexible and powerful Salesforce DX commands. Therefore, Salesforce CLI with Salesforce DX is the optimal choice for a robust, automated source-driven deployment strategy.
Question 27:
Example 1:
AggregateResult[] groupedResults = [SELECT CampaignId, AVG(Amount) FROM Opportunity GROUP BY CampaignId];
Which two of the examples above have correct System.debug statements? (Choose two.)
A. Example 1 B. Example 2 C. Example 3 D. Example 4
A. Example 1 B. Example 2
Question 28:
A developer writes a Lightning web component that displays a dropdown list of all custom objects in the org from which a user will select. An Apex method prepares and returns data to the component.
What should the developer do to determine which objects to include in the response?
A. Check the isCustom() value on the sObject describe result. B. Use the getCustomObject() method from the Schema class. C. Import the list of all custom objects from @salesforce/schema. D. Check the getObjectType() value for Custom or Standard on the sObject describe result.
A. Check the isCustom() value on the sObject describe result.
Explanation
To programmatically identify custom objects in Apex, developers utilize Schema Describe information . The Schema.getGlobalDescribe() method returns a map of all object tokens in the org. By iterating through these tokens and calling the getDescribe() method on each, the developer can access various properties of the object's metadata.
The specific property to distinguish between standard and custom objects is the isCustom() method (Option A). This boolean method returns true if the object is a custom object (including custom settings and custom metadata types) and false if it is a standard platform object.
Option C is incorrect because @salesforce/schema is used in LWC to import references to specific known objects/fields, not to discover the entire org's metadata dynamically. Option D is incorrect as getObjectType() returns an SObjectType token, not a string value like 'Custom'. Option B is incorrect because there is no getCustomObjects() method in the standard Schema class; discovery must be done via the global describe map.
Question 29:
To avoid duplicating code and improve maintainability, how should Universal Containers implement an API integration for code reuse?
A. Create a reusable Apex class for the API integration and invoke it from the relevant Apex classes. B. Use a separate Apex class for each API endpoint to encapsulate the integration logic. C. Store the API integration code as a static resource and reference it in each Apex class. D. Include the API integration code directly in each Apex class that requires it.
A. Create a reusable Apex class for the API integration and invoke it from the relevant Apex classes.
Explanation
The fundamental principle of DRY (Don't Repeat Yourself) in Apex development dictates that logic used in multiple places should be centralized. For API integrations, this typically involves creating a Utility or Service Class (Option A) .
This class handles the common "plumbing" of the integration:
Retrieving Named Credentials.
Setting headers (Content-Type, Timeout).
Standardizing error handling and logging.
Serializing and deserializing JSON payloads.
By invoking this central class from various triggers, batch jobs, or controllers, the developer ensures that any change to the API (such as a version update or header change) only needs to be made in one place . Option B leads to "class sprawl" and duplicate boilerplate code. Option C is incorrect as Static Resources cannot contain executable Apex code. Option D is the definition of poor maintainability.
Question 30:
A developer wrote a Visualforce page for Sales Reps to add products to an order. The page takes a URL query parameter, productFamily, which filters the product results. The test method for the filter behavior has an assertion failing due to an incorrect number of results.
Why could the test be failing? (Choose two.)
A. The test does not call Test.startTest() B. The test does not create product data C. The test is not run by a System Administrator D. The test does not set the current page reference
B. The test does not create product data D. The test does not set the current page reference
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.