Salesforce PDI Online Practice
Questions and Exam Preparation
PDI Exam Details
Exam Code
:PDI
Exam Name
:Salesforce Certification for Platform Developer I (Plat-Dev-201)
Certification
:Salesforce Certifications
Vendor
:Salesforce
Total Questions
:270 Q&As
Last Updated
:Jul 13, 2026
Salesforce PDI Online Questions &
Answers
Question 31:
A developer has identified a method in an Apex class that performs resource intensive actions in memory by iterating over the result set of a SOQL statement on the account. The method also performs a DML statement to save the changes to the database.
Which two techniques should the developer implement as a best practice to ensure transaction control and avoid exceeding governor limits? Choose 2 answers
A. Use the @ReadOnly annotation to bypass the number of rows returned by a SOQL. B. Use partial DML statements to ensure only valid data is committed. C. Use the System.limit class to monitor the current CPU governor limit consumption. D. Use the Database.Savepoint method to enforce database integrity.
B. Use partial DML statements to ensure only valid data is committed. D. Use the Database.Savepoint method to enforce database integrity.
Explanation
B: Using partial DML statements (e.g., Database.insert(list, false)) allows only valid records to be committed while identifying invalid ones, avoiding runtime errors.
D: The Database.Savepoint method ensures transactional control by allowing rollback to a specific savepoint if an error occurs.
Why not other options?
A: The @ReadOnly annotation is for read-only operations and would not allow DML operations.
C: The System.Limit class helps monitor limits but does not directly control transaction behavior.
References: Best Practices for Apex Transactions
Question 32:
A custom Visualforce controller calls the ApexPages.addMessage() method, but no messages are rendering on the page.
Which component should be added to the Visualforce page to display the message?
B
Explanation
Option B: The component renders all messages added to the ApexPages messages collection on a Visualforce page, including those added by the ApexPages.addMessage() method.
Not Suitable:
Option A: is for specific fields, not for the general messages collection.
Option C: is used for displaying a single, static message, not the dynamic collection of messages.
Option D: does not display messages.
Question 33:
Which Lightning Web Component custom event property settings enable the event to bubble up the containment hierarchy and cross the Shadow DOM boundary?
A. bubbles: true, composed: false B. bubbles: false, composed: false C. bubbles: true, composed: true D. bubbles: false, composed: true
C. bubbles: true, composed: true
Explanation
Why These Settings?
bubbles: true: Enables the event to propagate up the containment hierarchy.
composed: true: Allows the event to cross the Shadow DOM boundary.
Why Not Other Options?
Other combinations (e.g., bubbles: false) prevent the event from propagating or crossing the Shadow DOM boundary.
Custom Events in LWC: https://developer.salesforce.com/docs/component-library/documentation/en /lwc/lwc.events_create_dispatch
Question 34:
Consider the following code snippet:
As part of the deployment cycle, a developer creates the following test class:
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. Query the Administrator use into memory and enclose lines 15 and 16 within the system,runAs (use); method. B. Query the Standard User into memory and enclose lines 15 and 16 within the system ,runAs; method. C. Add @Istest% seeAllDataTrue; to line 12 and enclose lines 15 and 16 within Test .set(Test); and test ste-ptest();. D. Add System, runAs (Use; to line 14 and enclose line 15 within Test, startTest); and Test ().
B. Query the Standard User into memory and enclose lines 15 and 16 within the system ,runAs; method.
Explanation
By default, Apex tests run in system context and do not enforce sharing rules. However, the getAllAccounts method is defined in a with sharing class, so sharing rules must be applied to correctly test user-level access.
To accurately simulate how a Standard User sees the data, the test must run in the context of that user. This is accomplished using System.runAs(), which switches the execution context to the specified user and enforces sharing rules.
Example of corrected test method:
Apex Testing Best Practices ?Using System.runAs()
Question 35:
A developer has a Visualforce page and custom controller to save Account records. The developer wants to display any validation rule violations to the user.
How can the developer make sure that validation rule violations are displayed?
A. Add custom controller attributes to display the message. B. Use a try/catch with a custom exception class. C. Include on the Visualforce page. D. Perform the DML using the database.unsert() method,
C. Include on the Visualforce page.
Explanation
Validation Rule Violations:
Salesforce automatically throws exceptions for validation rule violations during DML operations.
A. The record will not be created and an exception will be thrown. B. The record will not be created and no error will be reported. C. The record will be created and no error will be reported. D. The record will be created and a message will be in the debug log.
B. The record will not be created and no error will be reported.
Explanation
Because Database.insert(a, false) uses partial success mode, Salesforce does not throw a DML exception when the record fails validation. Since the Account record is missing required fields, the insert operation fails, the record is not created, and no exception is thrown unless the result is explicitly checked in the returned Database.SaveResult.
Question 37:
Flow Builder uses an Apex action to provide additional information about multiple Contacts, stored in a custom class, ContactInfo.
Which is the correct definition of the Apex method that gets the additional information?
A. Option A B. Option B C. Option C
C. Option C
Explanation
An Invocable Method must be declared as public static. It must accept exactly one parameter of type List and must return a List.
Option C meets all Invocable Method signature requirements.
Option A is invalid because the parameter is not a List and the return type is not a List. Option B is invalid because the method is not static.
Question 38:
A developer is creating a page that allows users to create multiple Opportunities. The developer is asked to verify the current user's default Opportunity record type, and set certain default values based on the record type before inserting the record.
How can the developer find the current user's default record type?
A. Create the opportunity and check the opportunity. recordtype, which will have the record ID of the current user's default record type, before inserting. B. Query the Profile where the ID equals userinfo.getprofileID () and then use the profile opportunity. getdefaultresoratype (} method, C. Use the Schema.userInfo.Opportunity.getDefaultRecordType() method. D. Use Opportunity.SObjectType.getDescribe().getRecordTypeInfos() to get a list of record types, and iterate trought them until isdefaultRecordTypeMapping() is true.
D. Use Opportunity.SObjectType.getDescribe().getRecordTypeInfos() to get a list of record types, and iterate trought them until isdefaultRecordTypeMapping() is true.
Explanation
This method allows the developer to retrieve all available record types and identify the default record type for the current user by checking the isDefaultRecordTypeMapping() attribute.
Example:
Question 39:
A developer wants to send an outbound message when a record meets a specific criteria.
Which two features satisfy this use case?
A. Flow Builder can be used to check the record criteria and send an outbound message. B. Approval Process can be used to check the record criteria and send an outbound message without Apex code. C. Entitlement Process can be used to check the record criteria and send an outbound message without Apex code. D. Next Best Action can be used to check the record criteria and send an outbound message.
A. Flow Builder can be used to check the record criteria and send an outbound message. B. Approval Process can be used to check the record criteria and send an outbound message without Apex code.
Explanation
Flow Builder:
Flow Builder can evaluate record criteria using a Decision element and then send an outbound message using the "Action" element.
Allows automation without Apex.
Approval Process:
Approval Processes can evaluate criteria and trigger outbound messages as one of the associated actions.
Why Not Other Options?
C. Entitlement Process: Focuses on managing entitlements, not triggering outbound messages.
D. Next Best Action: Used for recommendations and guided actions, not for triggering outbound messages.
Approval Process Documentation: https://help.salesforce.com/s/articleView?id=approval_defining.htm
Question 40:
Universal Containers (UC) is developing a process for their sales teams that requires all sales reps to go through a set of scripted steps with each new customer they create.
In the first step of collecting information, UC's ERP system must be checked via a REST endpoint to see if the customer exists. If the customer exists, the data must be presented to the sales rep in Salesforce.
Which two should a developer implement to satisfy the requirements? Choose 2 answers
A. Flow B. Invocable method C. Future method D. Trigger
A. Flow B. Invocable method
Explanation
A: A Flow can guide sales reps through a set of scripted steps and call an Apex action to interact with an external REST endpoint.
B: An Invocable method is used to make an Apex method callable from a Flow. This method can call the REST endpoint and return the data for display.
Why not other options?
C: Future methods are asynchronous and cannot return data to the user in real time.
D: Triggers are used for database events, not for guiding users through scripted processes or making REST calls.
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 PDI exam preparations
and Salesforce certification application, do not hesitate to visit our
Vcedump.com to find your solutions here.