Updated Apr-2026 Test Engine to Practice Test for PDII Exam Questions and Answers!
Platform Developer II Certification Sample Questions and Practice Exam
To prepare for the PDII Exam, developers should have a solid understanding of Apex, Visualforce, and Lightning components. They should also be familiar with Salesforce development best practices and have experience in designing and implementing complex business logic. Developers can take advantage of various resources available online, including Salesforce's Trailhead platform, which offers a range of courses and modules designed to help developers prepare for the PDII Exam. Additionally, developers can attend training courses offered by Salesforce partners or attend Salesforce events and conferences to learn more about the latest developments in Salesforce development.
NEW QUESTION # 47
There is an Apex controller and a Visualforce page in an org that displays records with a custom filter consisting of a combination of picklist values selected by the user. The page takes too long to display results for some of the input combinations, while for other input choices it throws the exception, "Maximum view state size limit exceeded". What step should the developer take to resolve this issue?
- A. Remove instances of the transient keyword from the Apex controller to avoid the view state error.
- B. Split the layout to filter records in one Visualforce page and display the list of records in a second page using the same Apex controller.
- C. Adjust any code that filters by picklist values since they are not indexed.
- D. Use a StandardSetController or SOQL LIMIT in the Apex controller to limit the number of records displayed at a time.
Answer: D
Explanation:
The two symptoms described-slow load times and "Maximum view state size limit exceeded"-are both caused by Large Data Volumes (LDV) being handled improperly in the UI. When a user selects a filter that returns thousands of records, the SOQL query takes longer to execute, and the resulting list is stored in the controller's memory. Because Visualforce serializes all non-transient controller variables into a hidden form field (the View State), large lists quickly exceed the 135KB limit.
The correct resolution is to implement Pagination (Option D). By using the StandardSetController, a developer can easily manage large sets of data by loading only a small subset (e.g., 20 records) into the View State at a time. Users can then navigate through "Pages" of data. Alternatively, adding a LIMIT to the SOQL query prevents the application from attempting to process more data than the platform limits allow.123 Option A is incorrect because picklist fields can be indexed by Salesforce Support or if they are part of a custom index. Option B is the opposite of what is neede4d; adding transient reduces the View State. Option C adds unnecessary complexity without addressing the underlying data volume issue. Using a StandardSetController provides a built-5in, effi6cient way to handle large result sets while keeping the View State small and the page responsive.
NEW QUESTION # 48
Consider the following code snippet:
Which governor limit is likely to be exceeded when the trigger runs when a scope of 200 newly inserted accounts?
- A. Total number of SOQL queries issued
- B. Total number of DML statements issued
- C. Total number of records processed as a result of DML
- D. Total number of SOQL queries issued
Answer: B
NEW QUESTION # 49
Consider the following queries. For these queries, assume that there are more than 200,000 Account records.
These records include soft-deleted records; that is, deleted records that are still in the Recycle Bin. Note that there are two fields that are marked as External Id on the Account. These fields are Customer_Number__c and ERP_Key__c.
Which two queries are optimized for large data volumes? Choose 2 answers
- A. SELECT Id FROM Account WHERE Name != NULL
- B. SELECT Id FROM Account WHERE Name != ' ' AND Customer Number c = 'ValueA'
- C. SELECT Id FROM Account WHERE Id IN : aListVariable
- D. SELECT Id FROM Account WHERE Name != ' ' AND IsDeleted = false
Answer: B,C
NEW QUESTION # 50
How can Apex class functionality be exposed for invocation from a Lightning process? Choose 2 answers
- A. Expose the class as a custom REST API.
- B. Extend the ProcessInvocable base class.
- C. Implement the Process.Plugin interface.
- D. Use the @InvocableMethod annotation.
Answer: C,D
NEW QUESTION # 51
A developer has a requirement to query three fields (Id, Name, Type) from an Account; and first and last names for all Contacts associated with the Account.
Which option is the preferred, optimized method to achieve this for the Account named 'Ozone Electronics'?
- A.

- B.

- C.

- D.

Answer: C
Explanation:
The preferred, optimized method to achieve this for the Account named 'Ozone Electronics' is Option C. This option uses the SOQL query SELECT Id, Name, Type, (SELECT FirstName, LastName FROM Contacts) FROM Account WHERE Name = 'Ozone Electronics' LIMIT 1. This query uses the nested query syntax to query the related Contacts for the Account, and the WHERE clause to filter the Account by the Name field. The query also uses the LIMIT clause to return only one record, which improves the performance and avoids hitting the query row limit. Option A is incorrect, as it uses the JOIN syntax, which is not supported by SOQL. Option B is incorrect, as it uses the SELECT * syntax, which is not supported by SOQL. Option D is incorrect, as it uses two separate queries, which is less efficient and consumes more query resources than a single query. Reference: [SOQL SELECT Syntax], [SOQL Relationships], [SOQL and SOSL Reference]
NEW QUESTION # 52
A Visualforce page contains an industry select list and displays a table of Accounts that have a matching value in their Industry field. <apex:selectList value=",!selectedIndustry- "> <apex:selectOptions values="{!industries}"/> </apex:selectList> When a user changes the value in the industry select list, the table of Accounts should be automatically updated to show the Accounts associated with the selected industry.
What is the optimal way to implement this?
- A. Add an <apex: actionSupport> within the <apex: selectOptions>.
- B. add an <apex: actionFunction> within the <apex:selectList>.
- C. Add an <apex: actionFunction> within the <apex:selectOptions>.
- D. Add an <apex: actionSupport> within the <apex:selectList>.
Answer: D
NEW QUESTION # 53
What should be added to the setup, in the location indicated, for the unit test above to create the controller extension for the test?
A)
B)
C)
D)
- A. Option D
- B. Option C
- C. Option B
- D. Option A
Answer: C
NEW QUESTION # 54
Universal Containers needs to integrate with their own, existing, internal custom web application. The web application accepts JSON payloads, resizes product images, and sends the resized images back to Salesforce.
What should the developer use to implement this integration?
- A. An Apex trigger that calls an @future method that allows callouts910
- B. A flow with an outbound message that contains a session ID1314
- C. A flow that calls an @future method that allows callouts1112
- D. A platform event that makes a callout to the web application1516
Answer: A
Explanation:
Comprehensive and 19Detailed 150 to 250 words of Explanation:20
This integration requiremen21t involves two specific needs: sending a custom JSON payload and handling a response that involves updating data in Salesforce. Outbound Messaging (Option C) is a declarative tool, but it is limited to XML/SOAP protocols and cannot send JSON. Therefore, a custom programmatic solution using Apex is required to construct and send the JSON payload to the external REST service.
Since the integration must be triggered by an event in Salesforce (likely the upload or update of a product record), an Apex trigger is the most direct starting point. However, as noted in previous questions, callouts cannot be performed directly within a trigger's execution context because they would block the database transaction. The developer must use asynchronous processing to handle the callout. An @future(callout=true) method is the standard way to achieve this. The trigger captures the necessary data, passes it to the future method, and the future method then performs the HTTP request to the external application.
Once the external application resizes the image, it can use the Salesforce REST API to send the resized file back to Salesforce. While Platform Events (Option D) are a modern alternative for event-driven architectures, they would still require an asynchronous subscriber (like a trigger or a flow) to actually perform the callout, making the Trigger + Future method combination the most straightforward and traditional answer for this PDII scenario.
NEW QUESTION # 55
Universal Containers implements a private sharing model for the Convention Attendee co custom object. As part of a new quality assurance effort, the company created an Event_Reviewer_c user lookup field on the object.
Management wants the event reviewer to automatically gain ReadWrite access to every record they are assigned to.
What is the best approach to ensure the assigned reviewer obtains Read/Write access to the record?
- A. Create a before insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.
- B. Create a criteria-based sharing rule on the Convention Attendee custom object to share the records with a group of Event Reviewers.
- C. Create an after insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.
- D. Create criteria-based sharing rules on the Convention Attendee custom object to share the records with the Event Reviewers,
Answer: C
NEW QUESTION # 56
A company recently deployed a Visualforce page with a custom controller that has a data grid of information about Opportunities in the org. Users report that they receive a "Maximum view state size limit" error message under certain conditions.
According to Visualforce best practice, which three actions should the developer take to reduce the view state?
(Choose three.)
- A. Use the transient keyword in the Apex controller for variables that do not maintain state
- B. Use the final keyword in the controller for variables that will not change
- C. Use filters and pagination to reduce the amount of data
- D. Use the private keyword in the controller for variables
- E. Refine any SOQL queries to return only data relevant to the page
Answer: B,C,E
NEW QUESTION # 57
A company wants to implement a new call center process for handling customer service calls. It requires service reps to ask for the caller's account number before proceeding with the rest of their call script.
Following best practices, what should a developer use to meet this requirement?
- A. Flow Builder
- B. Apex Trigger
- C. Process Builder
- D. Approvals
Answer: C
NEW QUESTION # 58
A developer notices the execution of all the test methods in a class takes a long time to run, due to the initial setup of all the test data that is needed to perform the tests. What should the developer do to speed up test execution?
- A. Reduce the amount of test methods in the class.12
- B. Define a method that creates test data and annotate with @createData.
- C. Ensure proper usage of test data factory in all test methods.34
- D. Define a method that creates test data and annotate with @testSetup.
Answer: D
Explanation:
Comprehens7ive and Detailed 150 8to 250 words of Explanation:
In Salesforce Apex testing, the @testSetup annotation is a powerful tool designed to improve test performance and reduce code redundancy. When a method is marked with @testSetup, it executes once before any of the individual test methods in the class run. The data created in this method is then persisted for the entire class.
The primary performance benefit comes from how Salesforce handles this data: the platform creates a
"snapshot" of the database state after the setup method finishes. For every subsequent test method in the class, the system simply rolls back the database to this snapshot rather than re-executing the data creation logic. This significantly reduces the time spent on DML operations, which are often the most time-consuming part of a test suite.
Option D (Data Factories) is a best practice for code reuse, but if called inside every test method, it still results in redundant DML operations. Options A and B are incorrect; @createData is not a valid Salesforce annotation, and reducing the number of tests sacrifices code coverage and quality. By using @testSetup, a developer ensures that heavy data initialization happens only once, leading to faster execution cycles and more efficient resource usage during deployments.
NEW QUESTION # 59
Consider the controller code above that is called from a Lightning component and returns data wrapped in a class.
Consider the controller code above that is called from a Lightning component and returns data wrapped in a class.
The developer verified that the Queries return a single record each and there is error handing in the Lightning component, but the component is not getting anything back when calling the controller getSomeData().
What is wrong?
- A. The member's Name and Option of the class MyDataWrapper should be annotated with @AuraEnabled too.
- B. The member's Name and Option should not be declared public.
- C. Instances of Apex classes such as MyDataWrapper cannot be returned to a Lightning component.
- D. The member's Name and Option should not have getter and setter.
Answer: A
NEW QUESTION # 60
A developer is integrated with a legacy on-premises SQL database.
What should the developer use to ensure the data being integrated is matched to the right records in Salesforce?
- A. External Object
- B. Lookup field
- C. External id field
- D. Formula field
Answer: C
NEW QUESTION # 61
A page throws an 'Attempt to dereference a null object' error for a Contact.
What change in the controller will fix the error?
- A. Declare a static final Contact at the top of the controller.
- B. Use a condition in the getter to return a new Contact if it is null.
G Change the setter's signature to return a Contact. - C. Change the getter's signature to be static Contact.
Answer: B
Explanation:
The error 'Attempt to dereference a null object' often occurs when trying to access a member of a null object.
By checking if the object is null in the getter method and returning a new instance if it is, the error can be prevented.
References:
Apex Developer Guide
NEW QUESTION # 62
Refer to the following code snippet:
A developer created a JavaScript function as part of a Lightning web component (LWC) that surfaces information about Leads by wire calling geyFetchLeadList whencertain criteria are met.
Which three changes should the developer implement in the Apex class above to ensure the LWC can display data efficiently while preserving security?
Choose 3 answers
- A. Implement the with keyword in the class declaration.
- B. Annotate the Apex method with @AuraEnabled(Cacheable=True).
- C. Annotate the Apex method with @AuraEnabled.
- D. Implement the with sharing keyword in the class declaration.
- E. Use the WZ E D clause within the SOQL query.
Answer: B,C,D
Explanation:
The Apex class needs to have the method annotated with @AuraEnabled to expose it to the LWC. The 'with sharing' keyword ensures that the data access is enforced according to the user's permissions.
@AuraEnabled(cacheable=true) allows client-side caching for improved performance.
References:
@AuraEnabled Annotation: Apex Developer Guide
Enforcing Sharing Rules: Apex Developer Guide
NEW QUESTION # 63
After a platform event is defined in a Salesforce org, events can be published via which mechanism?
- A. External Apps use an API to publish event messages.
- B. Internal Apps can use outbound messages.
- C. External Apps require the standard Streaming API.
- D. Internal Apps can use entitlement processes.
Answer: A
Explanation:
Platform Events follow an event-driven architecture that allows for seamless integration between internal Salesforce processes and external applications. Once an event is defined, it must be "published" to the event bus to be seen by subscribers.
External Applications (Option C) publish platform events by using the Salesforce REST, SOAP, or Pub/Sub APIs. Essentially, an external app "inserts" a record into the event object (e.g., Order_Event__e). Since platform events are treated as a special type of Salesforce object, the standard API create call acts as the publishing mechanism.
Option A is incorrect because the Streaming API is used for subscribing to events, not for publishing them.
Option B is incorrect because Outbound Messages are a legacy SOAP-based notification tool and do not publish platform events. Option D is incorrect because Entitlement Processes are service-level management tools and are not part of the event-driven architecture.
For internal apps, platform events can also be published via Apex (using EventBus.publish()) or declaratively using Flow Builder. The key takeaway for external integration is that publishing is handled via standard Salesforce APIs, making it accessible to any system capable of making an HTTP request.
NEW QUESTION # 64
There are user complaints about slow render times of a custom data table within a Visualforce page that loads thousands of Account records at once. What can a developer do to help alleviate such issues?
- A. Use the standard Account List controller and implement pagination.
- B. Use the transient keyword in the Apex code when querying the Account records.
- C. Upload a third-party data table library as a static resource.
- D. Use JavaScript remoting to query the accounts.
Answer: A
NEW QUESTION # 65
What is a recommended practice with regard to the Apex CPU limit? Choose 2 answers
- A. Use Map collections to cache sObjects.
- B. Reduce view state in Visualforce pages.
- C. Optimize SOQL query performance.
- D. Avoid nested Apex iterations.
Answer: A,D
NEW QUESTION # 66
......
Certification dumps Salesforce Developers PDII guides - 100% valid: https://passking.actualtorrent.com/PDII-exam-guide-torrent.html