March Sale Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70percent

Salesforce PDII Salesforce Certified Platform Developer II (SP23) Exam Practice Test

Demo: 50 questions
Total 196 questions

Salesforce Certified Platform Developer II (SP23) Questions and Answers

Question 1

A company uses Dpportunities to track sales to their customers and their org has millions of Opportunities. They want to begin to track revenue over time through a related Revenue object.

As part of their initial implementation, they want to perform a one-time seeding of their data by automatically creating and populating Revenue records for Opportunities, based on complex logic.

They estimate that roughly 100,000 Opportunities will have Revenue records created and populated.

What is the optimal way to automate this?

Options:

A.

Use system, acheduladeb() to schedule a patakape.Scheduleable class.

B.

Use system, enqueuJob (| to invoke a gueusable class.

C.

Use Database. executeBatch () to invoke a Queueable class.

D.

Use Database. =executeBatch() to invoke a Database. Batchable class.

Question 2

Which statement is true regarding savepoints?

Options:

A.

You can roll back to any savepoint variable created in any order.

B.

Static variables are not reverted during a rollback.

C.

Reference to savepoints can cross trigger invocations.

D.

Savepoints are not limited by DML statement governor limits.

Question 3

A company has reference data stored in multiple custom metadata records that represent default information and delete behavior for certain geographic regions.

When a contact is inserted, the default information should be set on the contact from the custom metadata records based on the contact's address information.

Additionally, if a user attempts to delete a contact that belongs to a flagged region, the user must get an error message.

Depending on company personnel resources, what are two ways to automate this?

Choose 2 answers

Options:

A.

Remote action

B.

Flow Builder

C.

Apex trigger

D.

Apex invocable method

Question 4

A company has a custom component that allows users to search for records of a

certain object type by invoking an Apex Controller that returns a list of results

based on the user's input. When the search is completed, a searchComplete event

is fired, with the results put in a results attribute of the event. The component is

designed to be used within other components and may appear on a single page

more than once.

What is the optimal code that should be added to fire the event when the search has completed?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 5

Consider the following code snippet:

A developer created the following test class to provide the proper code coverage for the snippet above:

However, when the test runs, no data is returned and the assertion fails.

Which edit should the developer make to ensure the test class runs successfully?

Options:

A.

Implement the without sharing keyword in the searchFeaturs Apex class.

B.

Implement the seeAllData=true attribute in the @1sTest annotation.

C.

Enclose the method call within Test. startbest i) and @Test_stopTast |).

D.

Implement the setFixedSearchResult= method in the test class.

Question 6

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

Options:

A.

Annotate the Apex method with @AuraEnabled.

B.

Implement the with sharing keyword in the class declaration.

C.

Implement the with keyword in the class declaration.

D.

Use the WZ E D clause within the SOQL query.

E.

Annotate the Apex method with @AuraEnabled(Cacheable=True).

Question 7

Business rules require a Contact ta always be created when a new Account is created.

What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?

Options:

A.

Use setSaverpoint (1) and rollback() with a try-catch block.

B.

Use the Database. Insect method with a11orNone SEL LO alee,

C.

Use the Database. Delete method if the Contact insertion fails.

D.

Disable validation rules on Contacts and set default values with a trigger.

Question 8

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?

Options:

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

Question 9

A developer wrote a class named asccuntRisteryManager that relies on field history tracking. The class has a static method called getaccountHistory that Lakes in an Account as a parameter and returns a list of associated accountHistory object records.

The following test fails:

What should be done to make this test pass?

Options:

A.

Create Accountdistory records manually in the test setup and write a query to get them.

B.

Use @isTest (SeeAllData=true] to see historical data from the org and query for Accountdistory records.

C.

Use Test. isRunningTest (] in getAccountHistory() to conditionally return fake AccountHistory records.

D.

The tact method should he delated since this code cannat be tested

Question 10

A developer is asked to build a solution that will automatically send an email to the customer when an Opportunity stage changes. The solution must scale to allow for 10,000 emails per day. The criteria to send the email should be evaluated after certain conditions are met.

What is the optimal way to accomplish this?

Options:

A.

Use an Email Alert with Flow Builder.

B.

Use MassEmailMEssage () With an Apex trigger.

C.

Use a Workflow Email Alert.

D.

Use SingleEmailMessage() with an Apex trigger.

Question 11

A Visualforce page contains an industry select list and displays a table of Accounts that have a matching value in their Industry field.

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?

Options:

A.

Add an within the .

B.

Add an within the .

C.

Add an within the .

D.

Add an within the .

Question 12

A developer used custom settings to store some configuration data that changes occasionally. However, tests are now Failing in some of the sandboxes that were recently refreshed.

What should be done to eliminate this issue going forward?

Options:

A.

Set the setting type on the custom setting to List.

B.

Replace custom settings with static resources.

C.

Set the setting type on the custom setting to Hierarchy.

D.

Replace custom settings with custom metadata.

Question 13

Universal Containers (UC) has an ERP system that stores customer Information,

When an Account is created in Salesforce, the ERP system's REST endpoint for creating new customers must automatically be called with the Account information. If the call to the ERP

system falls, the Account should still be created. Accounts in the UC org are only created, one at a time, by users in the UC customer on-boarding department.

What should a developer implement to make the call to the ERP

system's REST endpoint?

Options:

A.

REST call from JavaScript

B.

Headless Quick Action

C.

Call a Queueable from a Trigger

D.

Apex Continuation

Question 14

A developer created the following test method:

The developer org has five accounts where the name starts with “Test”. The developer executes this test in the Developer Console.

After the test code runs, which statement is true?

Options:

A.

The test will fail.

B.

There will be no accounts where the name starts with "Test".

C.

There will be five accounts where the name starts with "Test".

D.

There will be six accounts where the name starts with "Test".

Question 15

A company needs to automatically delete sensitive information after seven years.

This could delete almost a million records every day.

How can this be achieved?

Options:

A.

Schedule an 3fuzure process to query records older than seven years, and then recursively invoke itself in 1,000 record batches to delete them,

B.

Use aggregate functions to query for records older than seven years, and then delete the aggrigateResults objects.

{civ [+] Schedule a batch Apex process to run every day that queries and deletes records older than seven years.

C.

Perform a SOSL statement to find records older than 7 years, and then delete the entire result set.

Question 16

Recently, users notice that fields that were recently added for one department suddenly disappear without warning.

Which two statements are true regarding these issues and resolution?

Choose 2 answers

Options:

A.

A sandbox should be created to use as a unified testing environment instead of deploying Change Sets directly to production.

B.

Page Layouts should never be deployed via Change Sets, as this causes Field-Level Security to be reset and fields to disappear.

C.

The administrators are deploying their own Change Sets over each other, thus replacing entire Page Layouts in production.

D.

The administrators are deploying their own Change Sets, thus deleting each other's fields from the objects in production.

Question 17

A developer is inserting, updating, and deleting multiple lists of records in a single transaction and wants to ensure that any error prevents all execution.

How should the developer implement error exception handling in their code to handle this?

Options:

A.

Use Database methods to obtain lists of Database.SaveResults.

B.

Use a try-catch statement and handle DML cleanup in the catch statement,

C.

Use Database.setSavepoint {} and Database.rollBack with a try-catch statement.

D.

Use a try-catch and use sObject.addError() on any failures.

Question 18

Universal Containers ne=ds to integrate with several external systems. The process Is Initiated when a record Is created in Salesforce, The remote systems do not require Salesforce to wait for a response before continuing.

What is the recommended best solution to accomplish this?

Options:

A.

PushTopic event

B.

Qutbound message

C.

Trigger with HTTP callout

D.

Platform event

Question 19

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?

Options:

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.

Question 20

Which two queries are selective SOQL queries and can be used for a large data set of 200,000 Account records?

Choose 2 answers

Options:

A.

SELECT Id FROM Account WHERE Name LIKE '!-NULL

B.

SELECT Id FRCM Account WHERE Name != ’ ’

C.

SELECT Id FRCM Account WHEP Name IN (List of Names) AND Customer_Number_c= 'ValueA

D.

SELECT Id FROM Account WHERE II IK (List of Account Ida)

Question 21

A developer is developing a reusable Aura component that will reside on an sObject Lightning page with the following HTML snippet:

How can the component"5 controller get the context of the Lightning page that the sObject is on without requiring additional test coverage?

Options:

A.

Add force:hasSobjectName to the implements attribute.

B.

Use the gerSubjectType method in an Apex class.

C.

Set the sObject type as a component attribute.

D.

Create a design attribute and configure via App Builder.

Question 22

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

Options:

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.

Question 23

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?

Options:

A.

Use JavaScript remoting to query the accounts.

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 the standard Account List controller and implement pagination.

Question 24

A developer has a test class that creates test data before making a mock callout but now receives a 'You have uncommitted work pending. Please commit or rollback before calling out’ error.

Which step should be taken to resolve the error?

Options:

A.

Ensure both the Insertion and mock callout occur after the I==L. stoptest_().

B.

Ensure the records are Inserted before the Tezt.startTest() statement and the mock callout occurs within a method annotated with @testSetup.

C.

Ensure both the insertion and mock callout occur after the Test.startTest().

D.

Ensure the records are inserted before the Test.startTess() statement and the mock callout occurs after the Test. Startest().

Question 25

An org has 2 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?

Options:

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

Question 26

What is a benefit of JavaScript remoting over Visualforce Remote Objects?

Options:

A.

Does not require any JavaScript code

B.

Supports complex server-side application logic

C.

Does not require any Apex code

D.

Allows for specified re-render targets

Question 27

Universal Containers develops a Salesforce application that requires frequent interaction with an external REST API.

To avoid duplicating code and improve maintainability, how should they implement the APL integration for code reuse?

Options:

A.

Use a separate Apex class for each API endpoint to encapsulate the integration logic,

B.

Include the API integration code directly in each Apex class that requires it.

C.

Create a reusable Apex class for the AFL integration and invoke it from the relevant Apex classes.

D.

Store the APT integration code as a static resource and reference it in each Apex class.

Question 28

Refer to the Aura component below:

A developer receives complaints that the component loads slowly.

Which change can the developer implement to make the component perform faster?

Options:

A.

Change the type of contactInfo to "Map”.

B.

Move the contents of

C.

Add a change event handler for showContactInfo.

D.

Change the default for showContactInfo to “False.

Question 29

When developing a Lightning web component, which setting displays lightninglayout-items im one column on small devices, such as mobile phones, and in two

columns on tablet-size and desktop-size screens?

Options:

A.

Set size="12" tablet-device-size="6"

B.

Set size="12" medium-device-size="6"

C.

Set size="6" mobile-device-size="12"

D.

Set size="6" small-device-size="12"

Question 30

Which method should be used to convert a Date to a String in the current user's locale?

Options:

A.

String.format

B.

Date.paras

C.

Date. format

D.

String.valueof

Question 31

Universal Containers analyzes a Lightning web component and its Apex controller

class that retrieves a list of contacts associated with an account. The code snippets

are as follows:

Based on the code snippets, what change should be made to display the contacts’ mailing addresses in the Lightning web component?

Options:

A.

Add a new method in the Apex controller class to retneve the mailing addresses separately and modify the Lightning web component to invoke this method.

B.

Extend the lightning-datatable component in the Lightning web component to include a column for the MailingAddress field.

C.

Modify the SOQL guery in the getAccountContacts method to include the MailingAddress field.

D.

Modify the SOQL query in the getAccountContacts method to include the MailingAddress field and update the columns attribute in javascript file to add Mailing address fields.

Question 32

Universal Containers (LIC) wants to develop a customer community to help their customers log issues with their containers. The community needs to function for their German- and Spanish-speaking customers also. UC heard that it's easy to create an international community using Salesforce, and hired a developer to build out the site.

What should the developer use to ensure the site is multilingual?

Options:

A.

Use custom labels to ensure custom messages are translated properly.

B.

Use custom settings to ensure custom messages are translated properly.

C.

Use custom objects to translate custom picklist values.

D.

Use custom metadata to translate custom picklist values.

Question 33

What is the optimal way to fix this?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 34

Consider the following code snippet:

Choose 2 answers

Options:

A.

Store the URL of the endpoint in a custom Label named endpointURL.

B.

Create a Named Credential, endpoint_NC, to store the endpoint and credentials.

C.

Use reg.setEndpoint(Label.endPoinrURL);,

D.

Use req.setEndpoint,calloat;eodPolat NC'); within the callout request.

Question 35

Consider the controller code below that is called from an Aura component and

returns data wrapped in a class.

The developer verified that the queries return a single record each and there is error handling in the Aura component, but the component is not getting anything back when calling the controller getSemeData.

‘What is wrong?

Options:

A.

Instances of Apex classes, such as MyDatsWrapper, cannot be returned to a Lightning component.

B.

The member's Name and option should not have getter and setter.

C.

The member's Name and option should not be declared public.

D.

The member's Kame and option of the class MyDataWrapper should be annotated with @AuraEnabled also.

Question 36

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?

Options:

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.

Question 37

An org has a requirement that an Account must always have one and only one Contact listed as Primary. So selecting one Contact will de-select any others. The client wants a checkbox on the Contact called 'Is Primary’ to control this feature.

The client also wants to ensure that the last name of every Contact is stored entirely in uppercase characters.

What is the optimal way to implement these requirements?

Options:

A.

Write a Validation Rule on the Contact for the Is Primary logic and a before update trigger on Contact for the last name logic.

B.

Write an after update trigger on Contact for the Is Primary logic and a separate before update trigger on Contact for the last name logic.

C.

Write a single trigger on Contact for both after update and before update and callout to helper classes to handle each set of logic.

D.

Write an after update trigger on Account for the Is Primary logic and a before update trigger on Contact for the last name logic.

Question 38

Consider the Apex controller below, that is called from an Aura component.

What is wrong with this code?

Options:

A.

Line 1: class must be global

8. Lines 1 and 6: class and method must be global

B.

Line 6: method must be static

C.

Line 8: method must first serialize the list to JSON before returning

Question 39

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?

Options:

A.

Define a method that creates test data and annotate with @testSetup.

B.

Define a method that creates test data and annotate with @createData.

C.

Ensure proper usage of test data factory in all test methods.

D.

Reduce the amount of test methods in the class.

Question 40

A developer needs to store variables to control the style and behavior of a Lightning Web Component.

Which feature can be used to ensure that the variables are testable in both Production and all Sandboxes?

Options:

A.

Custom setting

B.

Custom object

C.

Custom variable

D.

Custom metadata

Question 41

Assuming the CreateOneAccount class creates one account and implements the

Queueable interface, which syntax properly tests the Apex code?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 42

The Account object has a field, Audit_Code_c, that is used to specify what type of auditing the Account needs and a Lookup to User, zudizar_c, that is the assigned auditor. When an Account is initially created, the user specifies the Audit_Code c. Each User in the org has a unique text field, Audit_Code _e, that is used to automatically assign the correct user to the Account’s Auditor_c field.

What should be changed to most optimize the code’s efficiency?

Choose 2 answers

Options:

A.

Add an initial SOQL query to get all distinct audit codes.

B.

Build a Map> of audit code to accounts.

C.

Build a Map>of Account Id to audit codes.

D.

Add a WHERE clause to the SOQL query to filter on audit codes.

Question 43

Refer to the markup below:

A Lightning web component displays the Account name and two custom fields out of

275 that exist on the abject. The custom fields are correctly declared and

populated. However, the developer receives complaints that the component

performs slowly.

What can the developer do to improve the performance?

Options:

A.

Replace Layout-type =''Full1" with Layout-type="Partial”.

B.

Replace layout-type =''1" with fields=(fields}.

C.

Add density="compat" to the component.

D.

Add cache="true" to the component.

Question 44

Consider the following code snippet:

The Apex method is executed in an environment with a large data volume count for Accounts, and the query is performing poorly.

Which technique should the developer implement to ensure the query performs optimally, while preserving the entire result set?

Options:

A.

Create a formula field to combine the createdDate and RecordType value, then filter based on the formula.

B.

Break down the query into two individual queries and join the two result sets.

C.

Annotate the method with the @Future annotation

D.

Use the Database queryLocator method to retrieve the accounts.

Question 45

An Apex trigger creates a Contract record every time an Opportunity record is

marked as Closed and Won. This trigger is working great, except (due to a recent

acquisition) historical Opportunity records need to be loaded into the Salesforce

instance.

When a test batch of records are loaded, the Apex trigger creates Contract records.

A developer is tasked with preventing Contract records from being created when mass loading the Opportunities, but the daily users still need to have the Contract records created.

‘What is the most extendable way to update the Apex trigger to accomplish this?

Options:

A.

Add the Profile ID of the user who loads the data to the trigger, so the trigger will not fire for this user.

B.

Add a validation rule to the Contract to prevent Contract creation by the user who loads the data.

C.

Use a hierarchy custom setting to skip executing the logic inside the trigger for the user who loads the data.

D.

Use a list custom setting ta disable the trigger for the user who loads the data.

Question 46

A developer gets an error saying ‘Maximum Trigger Depth Exceeded.’

What is a possible reason to get this error message?

Options:

A.

A trigger is recursively invoked more than 16 times.

B.

The SOQL governor limits are being hit.

C.

There are numerous DML operations in the trigger logic.

D.

A flow trigger was included too many times.

Question 47

A developer created a Lightning web component that uses a lightning-record-edit-form to collect information about Leads. Users complain that they only see one error message at a time about their input when trying to save a Lead record.

What is the recommended approach to perform validations on more than one field, and display multiple error messages simultaneously with minimal JavaScript intervention?

Options:

A.

Try/catch/finally block

B.

External JavaScript library

C.

Validation rules

D.

Apex trigger

Question 48

Consider the Apex class below that defines a RemoteAction used on 2 Visualforce search page.

Which code snippet will assert that the remote action returned the correct Account?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 49

When the sales team views an individual customer record, they need to see recent interactions for the customer. These interactions can be sales orders, phone calls, or Cases. The date range for recent interactions will be different for every customer record type.

How can this be accomplished?

Options:

A.

Use batch Apex to query for the most recent interactions when the customer view screen is loaded.

B.

Use Lightning Flow to read the customer's record type, and then do a dynamic query for recent interactions and display on the View page.

C.

Use a Lightning component to query and display interactions based on record type that is passed in using a design:attribute from the Lightning page.

D.

Use a dynamic form on the customer record page to display recent interactions.

Question 50

Refer to the test method below:

The test method calls an @future method that increments the

Number_of_Times_Viewed__c value. The assertion is failing because the

Number of Times Viewed_c equals 0.

What is the optimal way to fix this?

Options:

A.

Change the assertion to system.asserciquals (0, acctAfter Number _Cf_Timea_Viewed__c).

B.

Add Test.atartTeat() before and Teat.stopTest() after inser= acct.

C.

Add rest.staztTest() before and Test.stopTess() after AuditUcil.incrementViewed.

D.

Change the initialization to acct. Number_Of_Times_Viewed_c = 1.

Demo: 50 questions
Total 196 questions