Salesforce pdii practice test

Salesforce Certified Platform Developer II

Last exam update: Dec 15 ,2025
Page 1 out of 14. Viewing questions 1-15 out of 202

Question 1

Instead of waiting to send emails to support personnel directly from the finish
method of a batch Apex process, Universal Containers wants to notify an external
system in the event that an unhandled exception occurs.
What is the appropriate publish/subscribe logic to meet this requirement?

  • A. Publish the error event using the Eventbus. publish () method.
  • B. No publishing is necessary. Have the external system subscribe to the BatchapexErrorEvent.
  • C. Publish the error event using the addError method.
  • D. Publish the error event with a Flow.
Mark Question:
Answer:

B


Explanation:
Use BatchApexErrorEvent for notifications. It's automatically triggered for unhandled exceptions in
batch Apex. No need for manual publishing. External systems can subscribe to this event to receive
notifications.
Reference: Batch Apex

User Votes:
A
50%
B 1 votes
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 2

A developer is asked to develop a new AppFxchange application. A feature of the program creates
Survey records when a Case reaches a certain stage and is of a certain Record Type. This feature
needs to be configurable, as different Salesforce instances require Surveys at different times.
Additionally, the out-of-the-box AppExchange app needs to come with a set of best practice settings
that apply to
most customers.
What should the developer use to store and package the custom configuration settings for the app?

  • A. Custom objects
  • B. Custom settings
  • C. Custom metadata
  • D. Custom labels
Mark Question:
Answer:

C


Explanation:
Custom metadata is best for storing configurable settings. It's deployable, packageable, and
upgradeable. Allows different configurations for different instances.
Reference: Custom Metadata Types

User Votes:
A
50%
B
50%
C 1 votes
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 3

A user receives the generic "An internal server error has occurred” while interacting
with a custom Lightning component.
What should the developer do to ensure a more meaningful message?

  • A. Add an onerror event handler to the tag.
  • B. Add an error-view component to the markup.
  • C. Use platform events to process the error
  • D. Use an AuraHandledexception in a try-catch block.
Mark Question:
Answer:

D


Explanation:
Use AuraHandledException in try-catch for custom errors. It enables sending meaningful, user-
friendly error messages to the Lightning component.
Reference: Handling Errors in Lightning Components

User Votes:
A
50%
B
50%
C
50%
D 1 votes
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 4

Universal Containers develops a Visualforce page that requires the inclusion of external JavaScript
and C55 files. They want to ensure efficient loading and caching of the page.
Which feature should be utilized to achieve this goal?

  • A. ActionFunction
  • B. PageBlockTable
  • C. Static resources
  • D. RemoteAction
Mark Question:
Answer:

C


Explanation:
Static resources are ideal for efficient loading and caching of external files in Visualforce. They allow
bundling and minimizing HTTP requests.
Reference: Using Static Resources

User Votes:
A
50%
B
50%
C 1 votes
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 5

A company manages information about their product offerings in custom objects named Catalog and
Catalog Item. Catalog Item has a master-detail field to Catalog, and each Catalog may have as many
as 100,000 Catalog Items.
Both custom objects have a CurrencylsoCode text field that contains the currency
code they should use. If a Catalog's CurrencylsoCode changes, all of its Catalog
Items’ CurrencylsoCodes should be changed as well.
What should a developer use to update the CurrencylsoCodes on the Catalog Items
when the Catalog's CurrencylsoCode changes?

  • A. A Database.Schedulable and Database.Batchacle class that queries the Catalog Item object and updates the Catalog Items if the Catalog CurrencylSoCode is different
  • B. An after insert trigger on Catalog that updates the Catalog Items if the Catalogs CurrencylsoCode is different
  • C. An after insert trigger on Catalog Item that updates the Catalog Items if the Catalog’s CurrencylsoCode is different
  • D. A Database. schedulable and Dazabase.Bazchacle class that queries the Catalog object and updates the Catalog Items if the Catalog CurrencylSoCode is different
Mark Question:
Answer:

A


Explanation:
Use Database.Batchable for handling large data sets. It can efficiently process 100,000 Catalog Items
asynchronously and update CurrencylsoCodes.
Reference: Using Batch Apex

User Votes:
A
50%
B
50%
C
50%
D 1 votes
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 6

How should a developer assert that a trigger with an asynchronous process has successfully run?

  • A. Create all test data in the test class, use system. runs {} to invoke the trigger, then perform assertions.
  • B. Insert records into Salesforce, use seeAllData=true, then perform assertions.
  • C. Create all test data, use future in the rest class, then perform assertions.
  • D. Create all test data in the test class, invoke Test.startTest{} and Test.etopTaat {} and then perform assertions.
Mark Question:
Answer:

D


Explanation:
Use Test.startTest() and Test.stopTest(). These methods ensure asynchronous code runs within test
execution and allows for accurate assertions.
Reference: Testing Asynchronous Apex

User Votes:
A
50%
B
50%
C
50%
D 1 votes
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 7

A company notices that their unit tests in a test class with many methods to create many records for
prerequisite reference data are slow.
What can a developer to do address the issue?

  • A. Turn off triggers, flows, and validations when running tests.
  • B. Move the prerequisite reference data setup to a TestDataFactory and call that from each test method.
  • C. Move the prerequisite reference data setup to a @testSetup method in the test class.
  • D. Move the prerequisite reference data setup to the constructor for the test class.
Mark Question:
Answer:

C


Explanation:
@testSetup method improves test performance. It allows data sharing across test methods within a
class, reducing redundant data creation.
Reference: Using the testSetup Method

User Votes:
A
50%
B
50%
C 1 votes
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 8

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 an after insert trigger on the Convention Attendee custom object, and use Apex Sharing Reasons and Apex Managed Sharing.
  • C. Create criteria-based sharing rules on the Convention Attendee custom object to share the records with the Event Reviewers,
  • D. Create a criteria-based sharing rule on the Convention Attendee custom object to share the records with a group of Event Reviewers.
Mark Question:
Answer:

B


Explanation:
Use Apex Managed Sharing with an after insert trigger. It allows dynamic record sharing based on
user-defined criteria like the Event_Reviewer_c field.
Reference: Apex Managed Sharing

User Votes:
A
50%
B 1 votes
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 9

Consider the following code snippet:

How should the <e-orders> component communicate to the <c-selected-orders
component that an order has been selected by the user?

  • A. Create and fire a component event.
  • B. Create and fire an application event.
  • C. Create and fire a standard DOM event.
  • D. Create and dispatch a custom event,
Mark Question:
Answer:

D


Explanation:
Create and dispatch a custom event. This approach allows LWC components to communicate
effectively, maintaining component encapsulation and reusability.
Reference: Communicating Between Lightning Web Components

User Votes:
A
50%
B
50%
C
50%
D 1 votes
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 10

A developer is creating a Lightning web component to display a calendar. The component will be
used in multiple countries. In some locales, the first day of the week is a Monday, or a Saturday, or a
Sunday. ‘What should the developer do to ensure the calendar displays accurately for users in every
locale?

  • A. Query the FirstDayofweek field from the Locale for the current user.
  • B. Import the @salesforce/i18n module and use the firstdayofweek internationalization property.
  • C. Use a custom metadata type to store key/value pairs.
  • D. Use UserInfo.getLocale() in the component.
Mark Question:
Answer:

B


Explanation:
Use the @salesforce/i18n module with the firstDayOfWeek property. It provides locale-aware
functionality essential for internationalization.
Reference: Internationalization with Lightning Web Components

User Votes:
A
50%
B 1 votes
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 11

Which statement is considered a best practice for writing bulk safe Apex triggers?

  • A. Add records to collections and perform DML operations against these collections.
  • B. Add LIMIT 50000 to every SOQL statement.
  • C. Perform all DML operations from within a future method.
  • D. Use the Database methods with allorNone set to £21s= instead of DML statements.
Mark Question:
Answer:

A


Explanation:
Bulk-safe triggers use collections to aggregate DML operations. This practice minimizes the number
of DML statements, which is essential for bulk processing.
Reference: Apex Developer Guide - Bulk Trigger Best Practices

User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 12

As part of their quoting and ordering process, a company needs to send POFs to their document
storage system's REST endpoint that supports OAuth 2.0. Each Salesforce user must be individually
authenticated with the document storage system to send the PDF.
What is the optimal way for a developer to implement the authentication to the REST endpoint?

  • A. Named Credential with an OAuth Authentication Provider
  • B. Named Credential with Password Authentication
  • C. Hierarchy Custom Setting with an OAuth token custom field
  • D. Hierarchy Custom Setting with 2 password custom field
Mark Question:
Answer:

A


Explanation:
Named Credentials with OAuth handle secure API calls. Individual authentication for each user with
OAuth 2.0 is managed through Named Credentials.
Reference: Named Credentials as Callout Endpoints

User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 13

What is the optimal way to fix this?
A)

B)

C)

D)

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Mark Question:
Answer:

C


Explanation:
Test.startTest() and Test.stopTest() should wrap the method call for resource allocation.
Test.setMock() sets a mock callout for the test to handle callouts.
Reference: Apex Developer Guide - Testing HTTP Callouts

User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 14

Refer to the test method below''

The test method calls a web service that updates an external system with Account
information and sets the Accounts 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.”
A)

B)

C)

D)

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Mark Question:
Answer:

B


Explanation:
The correct order in tests with callouts is Test.startTest(), then Test.setMock(), followed by the
method invocation, and finally Test.stopTest(). This ensures the mock callout is used.
Reference: Apex Developer Guide - Testing HTTP Callouts

User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 15

Refer to the following code snippets:
A developer is experiencing issues with a Lightning web component. The component must surface
information about Opportunities owned by the currently logged-in user.

When the component is rendered, the following message is displayed: "Error retrieving data”.
Which modification should be implemented to the Apex class to overcome the issue?

  • A. Use the Cacheable=true attribute in the Apex method,
  • B. Ensure the OWD for the Opportunity object is Public.
  • C. Edit the code to use the w. cut sharing keyword in the Apex class.
  • D. Use the Continuation=true attribute in the Apex method.
Mark Question:
Answer:

A


Explanation:
The @AuraEnabled(cacheable=true) attribute allows caching of method results on the client side,
reducing server trips for already fetched data, which is useful for read-only data.
Reference: Aura Components Developer Guide - AuraEnabled Annotation

User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
vote your answer:
A
B
C
D
0 / 1000
To page 2