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 231:
Which technique can run custom logic when a Lightning web component is loaded?
A. Use an <aura:handler> init event to call a function. B. Use the connectedCallback() method. C. Use the renderedCallback() method. D. Call $A.enqueueAction and pass in the method to call.
B. Use the connectedCallback() method.
Explanation
In Lightning Web Components (LWC), the component lifecycle is managed by standard Web Component lifecycle hooks. To run logic exactly once when the component is inserted into the Document Object Model (DOM), a developer should use the connectedCallback() method (Option B) .
The connectedCallback() is the LWC equivalent of Aura's init event. It is the ideal place to:
Perform initial data fetching (via imperative Apex).
Initialize internal state or variables.
Subscribe to a Lightning Message Service (LMS) channel.
Establish communication with the parent component.
Option A and D are Aura-specific syntax and are not valid in LWC. Option C (renderedCallback()) runs every time the component finishes a render cycle. Because a component can re-render many times (whenever a reactive property changes), placing initialization logic in renderedCallback can lead to performance issues or infinite loops if not guarded carefully. Therefore, connectedCallback() is the standard, most efficient way to handle "on load" logic in LWC.
Question 232:
An Apex trigger creates an Order__c record every time an Opportunity is won by a Sales Rep. Recently the trigger is creating two orders. What is the optimal method for a developer to troubleshoot this?
A. Run the Apex Test Classes for the Apex trigger to ensure the code still has sufficient code coverage. B. Turn off all Workflow Rules, then turn them on one at time to see which one causes the error. C. Add system.debug() statements to the code and use the Developer Console logs to trace the code. D. Set up debug logging for every Sales Rep, then monitor the logs for errors and exceptions.
C. Add system.debug() statements to the code and use the Developer Console logs to trace the code.
Explanation
When a trigger unexpectedly executes twice (recursion), it is typically due to the Salesforce Order of Execution . A common cause is a workflow rule, process, or flow updating the same record that initiated the transaction, which re-triggers the original Apex trigger. To identify exactly where this second execution is being initiated, the most effective technique is to use system.debug() statements in conjunction with the Developer Console logs (Option C) .
By placing debug statements at the start of the trigger (e.g., System.debug('Trigger Fired');), the developer can examine the execution log to see how many times that line appears. More importantly, the execution log provides a hierarchical "trace" of the entire transaction. The developer can look for entries like FLOW_CREATE_INTERVIEW or WF_RULE_EVAL_BEGIN between the two trigger execution blocks. This trace reveals exactly which automation (Flow, Workflow, or another Trigger) caused the record to be updated a second time.
Option B is inefficient and disruptive to production environments. Option D is too broad and doesn't provide the internal execution context. Option A checks for code validity but does not diagnose runtime logic issues in a live environment.
Tracing the execution through logs is the standard programmatic way to debug recursion and side effects in Salesforce.
Question 233:
A developer wrote the following method to find all the test accounts in the org:
What should be used to fix this falling test?
A. Test.loadData to set up expected data B. Test.setFixedSearchResults() method to set up expected data C. @isTest (See AllData=true) to access org data for the test D. @testSetup method to set up expected data
B. Test.setFixedSearchResults() method to set up expected data
Explanation
In Salesforce, SOSL (Search) queries behave differently than SOQL (Database) queries during unit tests. Because the search index is not updated in real time during a test transaction, an SOSL FIND statement will consistently return an empty list, even if records matching the criteria were just inserted within the same test method. This leads to the assertion failure seen in the developer's code. To overcome this, Salesforce provides the Test.setFixedSearchResults() method (Option B). This method allows a developer to define exactly which record IDs should be returned by any SOSL query executed during the test. When Test.setFixedSearchResults(list_of_ids) is called, the platform bypasses the actual search engine and returns the specified records. This ensures that the test remains deterministic and can verify the logic that processes the search results.
Option C (SeeAllData=true) is a poor practice and does not guarantee that the search index will be ready. Option A (Test.loadData) and Option D (@testSetup) are used for data creation but do not solve the underlying SOSL indexing limitation. Using setFixedSearchResults is the standard, documented way to test SOSL functionality in the Apex environment.
Question 234:
A developer is writing a Visualforce page that queries accounts in the system and presents a data table with the results. The users want to be able to filter the results based on up to five fields. However, the users want to pick the five fields to use as filter fields when they run the page.
Which feature of Apex code is required to facilitate this solution?
A. REST API B. Dynamic SOQL C. describeSObjects() D. SOSL queries
B. Dynamic SOQL
Explanation
When the structure of a query--such as the number of filters or the specific fields in the WHERE clause--is not known at compile-time and must be determined at runtime based on user input, "Dynamic SOQL" is the required feature. Unlike static SOQL, which is written directly in the Apex code and validated during compilation, Dynamic SOQL allows a developer to construct a query as a string.
In this scenario, the user might choose to filter by 'Industry' and 'AnnualRevenue' in one session, but only by 'BillingCity' in another. By using Database.query(queryString), the developer can programmatically append WHERE clauses to the base query string based on the selections made in the Lightning Web component. This provides the flexibility to handle the varying number of fields (up to five) without writing dozens of different static queries or complex "if-else" blocks that are difficult to maintain.
While describeSObjects() (Option C) can be used to get metadata about the fields, it doesn't execute the query. SOSL (Option D) is for text-based searching across multiple objects and is less efficient for specific field filtering on a single object. The REST API (Option A) is an external interface and not a feature of Apex used to solve internal filtering logic within an LWC controller. Therefore, Dynamic SOQL is the standard tool for building highly flexible, user-driven search interfaces on the platform.
Question 235:
What are two benefits of using External IDs? (Choose Two)
A. An External ID is indexed and can improve the performance of SOQL queries. B. An External ID field can be used to reference a unique ID from another, external system. C. An External ID can be a formula field to help create a unique key from two fields in Salesforce. D. An External ID can be used with Salesforce Mobile to make external data visible.
A. An External ID is indexed and can improve the performance of SOQL queries. B. An External ID field can be used to reference a unique ID from another, external system.
Question 236:
An Apex trigger and an Apex class increment a counter field, Edit_Count__c, each time a Case record is updated.
public class CaseTriggerHandler { public static void handle(List<Case> cases) {
for (Case c : cases) {
A. Edit_Count__c = c.Edit_Count__c + 1;}}}trigger CaseTrigger on Case (before update) {CaseTriggerHandler.handle(Trigger.new);}A new before-save record-triggered Flow on the Case object has recently been created in production. The Flow runs when a Case is created or updated. Since the Flow was added, users report that Edit_Count__c is being incremented more than once during a single Case edit.Which Apex code change will fix this problem? B. trigger CaseTrigger on Case (before update) {Boolean firstRun = true;if (firstRun) {CaseTriggerHandler.handle(Trigger.newMap);}firstRun = false;} C. public class CaseTriggerHandler {public static Boolean firstRun = true;public static void handle(List<Case> cases) {for (Case c : cases) { D. Edit_Count__c = c.Edit_Count__c + 1;}}}trigger CaseTrigger on Case (before update) {CaseTriggerHandler.firstRun = true;if (CaseTriggerHandler.firstRun) {CaseTriggerHandler.handle(Trigger.new);}CaseTriggerHandler.firstRun = false;} E. public class CaseTriggerHandler {public static Boolean firstRun = true;public static void handle(List<Case> cases) {for (Case c : cases) { F. Edit_Count__c = c.Edit_Count__c + 1;}}}trigger CaseTrigger on Case (before update) {CaseTriggerHandler.handle(Trigger.new);} G. public class CaseTriggerHandler {public static Boolean firstRun = true;public static void handle(List<Case> cases) {for (Case c : cases) { H. Edit_Count__c = c.Edit_Count__c + 1;}}}trigger CaseTrigger on Case (before update) {if (CaseTriggerHandler.firstRun) {CaseTriggerHandler.handle(Trigger.new);}CaseTriggerHandler.firstRun = false;}
D. Edit_Count__c = c.Edit_Count__c + 1;}}}trigger CaseTrigger on Case (before update) {CaseTriggerHandler.firstRun = true;if (CaseTriggerHandler.firstRun) {CaseTriggerHandler.handle(Trigger.new);}CaseTriggerHandler.firstRun = false;}
Question 237:
A developer is asked to look into an issue where a scheduled Apex is running into DML limits. Upon investigation, the developer finds that the number of records processed by the scheduled Apex has recently increased to more than 10,000.
What should the developer do to eliminate the limit exception error?
A. Use the @future annotation. B. Implement the Bathable interface. C. Use platform events. D. Implement the Queueable interface.
B. Implement the Bathable interface.
Explanation
The issue described involves hitting DML limits due to a high volume of records (over 10,000) being processed in a single transaction. In Salesforce, a single synchronous transaction or a standard Scheduled Apex job has strict governor limits on the number of DML statements (150) and the total number of records processed (10,000 for DML rows).
To resolve this, the developer should implement the Database.Batchable interface. Batch Apex is specifically designed to handle large data volumes by breaking the processing into smaller, manageable chunks (batches) of records (default 200). Each batch runs within its own transaction context, resetting the governor limits for that specific batch. This prevents the "Too many DML rows" exception. While Queueable (Option D) and @future (Option A) provide asynchronous processing, they are not inherently designed to iterate over large datasets in the same robust, governor-limit-safe manner as Batch Apex, particularly when the record count exceeds the thousands.
Question 238:
What is the optimal syntax for adding a link to a Case in a Visualforce page? (Choose two.)
A. <apex:outputLink value="{!URLFOR($Action.Case.Open, case)}" target="_blank">{!case.Name}</apex:outputLink> B. <apex:outputLink value="/{!case.Id}" target="_blank">{!case.Name}</apex:outputLink> C. <apex:outputLink value="{!URLFOR($Action.Case.View, case.Id)}" target="_blank">{!case.Name}</apex:outputLink> D. <apex:outputLink value="{!viewCase(case.Id)}" target="_blank">{!case.Name}</apex:outputLink>
B. <apex:outputLink value="/{!case.Id}" target="_blank">{!case.Name}</apex:outputLink> C. <apex:outputLink value="{!URLFOR($Action.Case.View, case.Id)}" target="_blank">{!case.Name}</apex:outputLink>
Question 239:
The Salesforce instance at Universal Containers currently integrates with a third-party company to validate mailing addresses via REST services. The third-party address verification system recently changed endpoint URLs for all their set vices from https://th-addreaa-service.3pc.com to https://plc1-mailsarvice.3pc.com.
Everything else remained the same. The developer updated code to reflect this endpoint change, but the mailing address validation service stopped working after the change.
What else should be done to complete this web service end point change?
A. Test the callout property using HttpCalloutMock. B. Add web service IP Addresses to Trusted IP Ranges m the Network Access security controls settings. C. Use a Custom Setting with the new endpoint Instead of hard coding the URL. D. Create a new Remote Site for the new endpoint URL.
D. Create a new Remote Site for the new endpoint URL.
Question 240:
A developer wrote a test class that successfully asserts a trigger on Account. It fires and updates data correctly in a sandbox environment. A salesforce admin with a custom profile attempts to deploy this trigger via a change set into the production environment, but the test class fails with an insufficient privileges error.
What should a developer do to fix the problem?
A. Add system.runAd () to the best class to execute the trigger as a user with the correct object permissions. B. Configure the production environment to enable "Run All tests as Admin User". C. Verify that Test, statement () is not inside a For loop in the test class. D. Add seeAllData=true to the test class to work within the sharing model for the production environment.
A. Add system.runAd () to the best class to execute the trigger as a user with the correct object permissions.
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.