Salesforce pdii practice test

Exam Title: Salesforce Certified Platform Developer II

Last update: Dec 07 ,2025
Question 1

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.
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

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 2

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
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

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 3

What is the optimal way to fix this?
A)

B)

C)

D)

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
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

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 4

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
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

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 5

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.
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

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 6

A developer is trying to decide between creating a Visualforce component or a Lightning component
for a custom screen.
Which functionality consideration impacts the final decision?

  • A. Does the screen need to be accessible from the Lightning Experience UI?
  • B. Does the screen need to be rendered as a PDF without using a thirdparty application?
  • C. Will the screen make use of a JavaScript framework?
  • D. Will the screen be accessed via a mobile app?
Answer:

B


Explanation:
Visualforce can render pages as PDFs, which Lightning Components cannot do. This functionality is
crucial if PDF rendering is required.
Reference: Visualforce Developer Guide - Rendering a Page as a PDF

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 7

Given the following code:

Assuming there were 10 Contacts and five Accounts created today, what is the expected result?

  • A. System.QueryException: Too many DML Statement errors on Contact
  • B. System.QueryException: List has more than one row for Assignment on Account
  • C. Systemn.LimitException: Too many SOQL Queries on Account
  • D. System.LimitException: Too many SOQL Queries on Contact
Answer:

B


Explanation:
The loop contains a SOQL query inside, causing it to run multiple times. This will throw a
QueryException because the Account query returns more than one row.
Reference: Apex Developer Guide - SOQL Queries

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 8

A developer is trying to access org data from within a test class.
Which sObject type requires the test class to have the (seeAllData=true)
annotation?

  • A. User
  • B. RecordType
  • C. Report
  • D. Profile
Answer:

C


Explanation:
https://salesforce.stackexchange.com/questions/149110/when-is-it-appropriate-to-use-seealldata-
true

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 9

An org has a requirement that addresses on Contacts and Accounts should be normalized to a
company standard by Apex code any time that they are saved.
What is the optimal way to implement this?

  • A. Apex triggers on Contact and Account that call a helper class to normalize the address
  • B. Apex trigger on Account that calls the Contact trigger to normalize the address
  • C. Apex triggers on Contact and Account that normalize the address
  • D. Apex trigger on Contact that calls the Account trigger to normalize the address
Answer:

A


Explanation:
Apex triggers on Contact and Account with a helper class is the best practice for code reuse and
maintaining clean trigger logic.
Reference: Apex Developer Guide - Triggers and Order of Execution

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Question 10

What is the best practice to initialize a Vizualforce page in a test class?

  • A. Use Test. setCurrentPage (Page. MyTeatPage);
  • B. Use Test. currantPage .getParamatars put (MyTaestPaga) ;
  • C. Use controller. currentPage. setPage (MyTastfage) ;
  • D. Use Test. setCurrentPage MyTestPags;
Answer:

A


Explanation:
Test.setCurrentPage(Page.MyTestPage) is used to set the context to a Visualforce page in tests,
allowing you to simulate a page request in a test method.
Reference: Apex Developer Guide - Testing Custom Controllers and Controller Extensions

vote your answer:
A
B
C
D
A 0 B 0 C 0 D 0
Comments
Page 1 out of 20
Viewing questions 1-10 out of 202
Go To
page 2