Month end Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70special

Salesforce PDII Salesforce Certified Platform Developer II ( Plat-Dev-301 ) Exam Practice Test

Page: 1 / 16
Total 161 questions

Salesforce Certified Platform Developer II ( Plat-Dev-301 ) Questions and Answers

Testing Engine

  • Product Type: Testing Engine
$37.5  $124.99

PDF Study Guide

  • Product Type: PDF Study Guide
$33  $109.99
Question 1

A company has an Apex process that makes multiple extensive database operations and web service callouts. The database processes and web services can take a long time to run and must be run sequentially. How should the developer write this Apex code without running into governor limits and system limitations?123

Options:

A.

Use Apex Scheduler to schedul4e each process.56

B.

Use Limits class to stop entire pr7ocess once governor limits are reached.8

C.

Use multip9le @future methods for each process and callout.

D.

Use Queueable Apex to chain the jobs to run sequentially.

Question 2

A business requires that every parent record must have a child record. A developer writes an Apex method with two DML statements to insert a parent record and a child record. A validation rule blocks child records from being created. The method uses a try/catch block to handle the DML exception. What should the developer do to ensure the parent always has a child record?

Options:

A.

Use Database.insert() and set the allOrNone parameter to true.

B.

Delete the parent record in the catch statement when an error occurs on the child record DML operation.

C.

Set a database savepoint to rollback if there are errors.

D.

Use addError() on the parent record if an error occurs on the child record.

Question 3

A developer has a Visualforce page that automatically assigns ownership of an Account to a queue upon save. The page appears to correctly assign ownership, but an assertion validating the correct ownership fails. What can cause this problem?

Options:

A.

The test class does not implement the Queueable interface.

B.

The test class does not retrieve the updated value from the database.

C.

The test class does not use the seeAllData=true annotation.

D.

The test class does not use the Bulk API for loading test data.

Question 4

Universal Containers wants to develop a recruiting app for iOS and Android via the standard Salesforce mobile app. It has a custom user interface design and offline access is not required. What is the recommended approach to develop the app?

Options:

A.

Salesforce SDK

B.

Lightning Web Components

C.

Lightning Experience Builder

D.

Visualforce

Question 5

A developer created an Apex class that updates an Account based on input from a Lightning web component. The update to the Account should only be made if it has not already been registered.

Java

account = [SELECT Id, Is_Registered__c FROM Account WHERE Id = :accountId];

if (!account.Is_Registered__c) {

account.Is_Registered__c = true;

// ...set other account fields...

update account;

}

What should the developer do to ensure that users do not overwrite each other’s updates to the same Account if they make updates at the same time?

Options:

A.

Add a try/catch block around the update.

B.

Use upsert instead of update.

C.

Use FOR UPDATE in the SOQL query.

D.

Include LastModifiedDate in the query to make sure it wasn’t recently updated.

Question 6

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 Test.stopTest().1

B.

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

C.

Ensure the records are inserted befo3re the Test.startTest() statement and the mock callout occurs after the Test.startTest().45

D.

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

Question 7

A company's support process dictates that any time a case is closed with a status of 'Could not fix,' an Engineering Review custom object record should be created and populated with information from the case, the contact, and any of the products associated with the case. What is the correct way to automate this using an Apex trigger?12

Options:

A.

A before update trigger on Case that creates the Engineering Review record and inserts it3456

B.

An after upset trigger on Case that creates the Engineering Review record and ins7erts it8910

C.

11 A before upset trigger on Case that creates the Engineering Review record and inserts it1213

D.

An after update trigger14 on Ca15se that creates the Engineering Review record and inserts it

Question 8

Refer to the code snippet below:

Java

public static void updateCreditMemo(String customerId, Decimal newAmount){

List toUpdate = new List();

for(Credit_Memo__c creditMemo : [Select Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50]) {

creditMemo.Amount__c = newAmount;

toUpdate.add(creditMemo);

}

Database.update(toUpdate,false);

}

A custom object called Credit_Memo__c exists in a Salesforce environment. As part of a new feature development, the developer needs to ensure race conditions are prevented when a set of records are mod1ified within an Apex transaction. In the preceding Apex code, how can the developer alter the que2ry statement to use SOQL features to prevent race conditions within a tr3ansaction?4

Options:

A.

[Select Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50 FOR UPDATE]

B.

[Select Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId USING SCOPE LIMIT 50]

C.

[Select Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50 FOR REFERENCE]

D.

[Select Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50 FOR VIEW]

Question 9

Consider the following code snippet:

HTML

Users of this Visualforce page complain that the page does a full refresh every time the Search button is pressed. What should the developer do to ensure that a partial refresh is made so that only t13he section identified with opportunityList is re-drawn on the screen?1415

Options:

A.

Enclose the DAT16A table within the tag.1718

B.

Implement the tag with immediate = true.

C.

Ensure the action method search returns null.19

D.

Implement the reRender attribute on the tag.

Question 10

Which code snippet processes records in the most memory efficient manner, avoiding governor limits such as "Apex heap size too large"?

Options:

A.

Java

Map opportunities = new Map([SELECT Id, Amount from Opportunity]);

for(Id oppId: opportunities.keySet()){

// perform operation here

}

B.

Java

for(Opportunity opp: [SELECT Id, Amount from Opportunity]){

// perform operation here

}

C.

Java

List opportunities = Database.query('SELECT Id, Amount from Opportunity');

for(Opportunity opp: opportunities){

// perform operation here

}

D.

Java

List opportunities = [SELECT Id, Amount from Opportunity];

for(Opportunity opp: opportunities){

// perform operation here

}

Question 11

A Salesforce developer is hired by a multi-national company to build a custom Lightning application that shows employees their employment benefits and earned commissions over time. The application must acknowledge and respect the user's locale context for dates, times, numbers, currency, and currency symbols. When using Aura components, which approach should the developer implement to ensure the Lightning application complies with the user's locale?3

Options:

A.

Use the $User global variable to retrieve the user preferences.4

B.

Create a Hierarchical custom setting to store user preferences.5

C.

Use the $Locale value provider to retrieve the user preferences.67

D.

Use the $Label global value provider.89

Question 12

A developer needs a Lightning web component to display in one column on phones and two columns on tablets/desktops. Which should the developer add to the code?

Options:

A.

Add size="12" medium-device-size="6" to the elements

B.

Add size="6" small-device-size="12" to the elements

C.

Add small-device-size="12" to the elements

D.

Add medium-device-size="6" to the elements

Question 13

An Apex trigger creates a Contract record every time an Opportunity record is marked as Closed and Won. A developer is tasked with preventing Contract records from being created when mass loading historical Opportunities, but the daily users still need the logic to fire. 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.

B.

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

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 to disable the trigger for the user who loads the data.

Question 14

A developer is tasked with creating a Lightning web component that allows users to create a Case for a selected product, directly from a custom Lightning page. The input fields in the component are displayed in a non-linear fashion on top of an image of the product to help the user better understand the meaning of the fields. Which two components should a developer use to implement the creation of the Case from the Lightning web component?161718

Options:

A.

lightning-record-form192021

B.

lightning-record-edit-form222324

C.

lightnin25g-input-field2627

D.

lightning-input2829

Question 15

Which select statement should be inserted to retrieve Tasks ranging from 12 to 24 months old, including archived tasks, and excluding deleted ones?

Java

Date initialDate = System.Today().addMonths(-24);

Date endDate = System.Today().addMonths(-12);

Options:

A.

[SELECT ... FROM Task WHERE What.Type = 'Account' AND isArchived=true AND CreatedDate => :initialDate ...]

B.

[SELECT ... FROM Task WHERE What.Type = 'Account' AND CreatedDate => :initialDate ... ALL ROWS]

C.

[SELECT ... FROM Task WHERE What.Type = 'Account' AND isDeleted=false AND CreatedDate => :initialDate ... ALL ROWS]

D.

[SELECT ... FROM Task WHERE What.Type = 'Account' AND isArchived=true AND CreatedDate => :initialDate ... ALL ROWS]

Question 16

Business rules require a Contact to 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 setSavePoint() and rollback() with a try-catch block.

B.

Use a Database Savepoint method with a try-catch block.

C.

Use the Database.Insert method with allOrNone set to false.

D.

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

Question 17

In an organization that has multi-currency enabled, a developer is tasked with building a Lighting component that displays the top ten Opportunities most recently accessed by the logged in user. The developer must ensure the Amount and LastModifiedDate field values are displayed according to the user’s locale. What is the most effective approach to ensure values displayed respect the user’s locale settings?1819

Options:

A.

Use the FORMAT ( ) function in the SOQL query.2021

B.

Use a wrapper class to format the values retrieved via SOQL.2223

C.

Use REGEX expressions to format the values retrieved via SOQL.2425

D.

Use the FOR VIEW clause in the SOQL query.2627

Question 18

A Salesforce Platform Developer is leading a team that is tasked with deploying a new application to production. The team has used source-driven development, and they want to ensure that the application is deployed successfully. What tool or mechanism should be used to verify that the deployment is successful?

Options:

A.

Force.com Migration Tool

B.

Apex Test Execution

C.

Salesforce DX CLI

D.

Salesforce Inspector

Question 19

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

Options:

A.

Supports complex server-side application logic

B.

Does not require any Apex code

C.

Does not require any JavaScript code

D.

Allows for specified re-render targets

Question 20

What are three reasons that a developer should write Jest tests for Lightning web components?

Options:

A.

To test basic user interaction

B.

To test a component’s non-public properties

C.

To test how multiple components work together

D.

To verify the DOM output of a component

E.

To verify that events fire when expected

Question 21

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

Options:

A.

Use Database methods to obtain lists of Database.SaveResults.

B.

Use Database.setSavepoint() and Database.rollBack() with a try-catch statement.

C.

Use a try-catch statement and handle DML cleanu22p in the catch statement.

D.

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

Question 22

Refer to the following code snippet:

Java

public class LeadController {

public static List getFetchLeadList(String searchTerm, Decimal aRevenue) {

String safeTerm = '%'+searchTerm.escapeSingleQuotes()+ '%';

return [

SELECT Name, Company, AnnualRevenue

FROM Lead

WHERE AnnualRevenue >= :aRevenue

AND Company LIKE :safeTerm

LIMIT 20

];

}

}

A developer created a JavaScript function as part of a Lightning web component (LWC) that surfaces information about Leads by wire calling getFetchLeadList when certain 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?1

Options:

A.

Use the WITH SECURITY_ENFORCED clause within the SOQL query.

B.

Implement the with sharing keyword in the class declaration.567

C.

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

D.

Implement the without sharing keyword in the class declaration.

E.

Annotate the Apex method with @AuraEnabled.

Question 23

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

Options:

A.

Static resources

B.

@RemoteAction

C.

D.

Question 24

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?

Options:

A.

Adjust any code that filters by picklist values since they are not indexed.

B.

Remove instances of the transient keyword from the Apex controller to avoid the view state error.

C.

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.

D.

Use a StandardSetController or SOQL LIMIT in the Apex controller to limit the number of records displayed at a time.

Question 25

Salesforce users consistently receive a "Maximum trigger depth exceeded" error when saving an Account. How can a developer fix this error?

Options:

A.

Split the trigger logic into two separate triggers.

B.

Modify the trigger to use the isMultiThread=true annotation.

C.

Convert the trigger to use the @future annotation, and chain any subsequent trigger invocations to the Account object.

D.

Use a helper class to set a Boolean to TRUE the first time a trigger is fired, and then modify the trigger to only fire when the Boolean is FALSE.

Question 26

Universal Containers is leading a development team that follows the source-driven development approach in Salesforce. As part of their continuous integration and delivery (CI/CD) process, they need to automatically deploy changes to multiple environments, including sandbox and production. Which mechanism or tool would best support their CI/CD pipeline in source-driven development?

Options:

A.

Salesforce CLI with Salesforce DX

B.

Change Sets

C.

Salesforce Extensions for Visual Studio Code

D.

Ant Migration Tool

Question 27

Millions of Accounts are updated every quarter from an external system. What is the optimal way to update these in Salesforce?

Options:

A.

Composite REST API

B.

SOAP API

C.

Bulk API

D.

Apex REST Web Service

Question 28

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.

Savepoints are not limited by DML statement governor limits.

D.

Reference to savepoints can cross trigger invocations.

Question 29

A software company uses a custom object, Defect__c, to track defects in their software. Defect__c has organization-wide defaults set to private. Each Defect__c has a related list of Reviewer__c records, each with a lookup field to User that is used to indicate that the User will review the Defect__c. What should be used to give the User on the Reviewer__c record read only access to the Defect__c record on the Reviewer__c record?34

Options:

A.

View All on Defect__c

B.

Criteria-based sharing56

C.

Lightning web component78

D.

Apex managed sharing910

Question 30

Which use case can be performed only by using asynchronous Apex?

Options:

A.

Querying tens of thousands of records

B.

Making a call to schedule a batch process to complete in the future

C.

Calling a web service from an Apex trigger

D.

Updating a record after the completion of an insert1

Question 31

Java

@isTest

static void testUpdateSuccess() {

Account acet = new Account(Name = 'test');

insert acet;

// Add code here

extension.inputValue = 'test';

PageReference pageRef = extension.update();

System.assertNotEquals(null, pageRef);

}

What should be added to the setup, in the location indicated, for the unit test above to create the controller extension for the test?

Options:

A.

AccountControllerExt extension = new AccountControllerExt(acet);

B.

ApexPages.StandardController sc = new ApexPages.StandardController(acet); AccountControllerExt extension = new AccountControllerExt(sc);

C.

ApexPages.StandardController sc = new ApexPages.StandardController(acet.Id); AccountControllerExt extension = new AccountControllerExt(sc);

D.

AccountControllerExt extension = new AccountControllerExt(acet.Id);

Question 32

Universal Containers uses Salesforce to track orders in an Order__c object. The Order__c object has private organization-wide defaults. The Order__c object has a custom field, Quality_Controller__c, that is a Lookup to User and is used to indicate that the specified User is performing quality control on the Order__c. What should be used to automatically give read only access to the User set in the Quality_Controller__c field?

Options:

A.

User managed sharing

B.

Record ownership

C.

Apex managed sharing

D.

Criteria-based sharing

Question 33

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, Auditor__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__c, that is used to automatically assign the correct user to the Account's Auditor__c field.

Trigger:

Java

trigger AccountTrigger on Account (before insert) {

AuditAssigner.setAuditor(Trigger.new);

}

Apex Class:

Java

public class AuditAssigner {

public static void setAuditor(List accounts) {

for (User u : [SELECT Id, Audit_Code__c FROM User]) {

for (Account a : accounts) {

if (u.Audit_Code__c == a.Audit_Code__c) {

a.Auditor__c = u.Id;

}

}

}

}

}

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

Options:

A.

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

B.

Build a Map> of audit code to accounts.

C.

Build a Map> of Account Id to audit codes.

D.

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

Question 34

A company wants to allow support managers to see all cases in the org, regardless of who owns them. However, they want to support agents to only see cases they own or cases owned by someone in their role or a subordinate role. Which sharing solution should a developer use to achieve this requirement?

Options:

A.

Sharing sets

B.

Apex managed sharing

C.

Role hierarchy

D.

Criteria-based sharing rules

Question 35

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?

Options:

A.

RecordType

B.

Report

C.

User

D.

Profile

Question 36

A developer sees test failures in the sandbox but not in production. No code or metadata changes have been actively made to either environment since the sandbox was created. Which consideration should be checked to resolve the issue?

Options:

A.

Ensure test classes are using SeeAllData = true.15

B.

Ensure the Apex classes are on the same API version.16

C.

Ensure the sandbox is on the same release as production.17

D.

Ensure that Disable Parallel Apex Testing is unchecked.18

Question 37

A query using OR between a Date and a RecordType is performing poorly in a Large Data Volume environment. How can the developer optimize this?

Options:

A.

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

B.

Annotate the method with the @Future annotation.

C.

Use the Database.querySelector method to retrieve the accounts.

D.

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

Question 38

A developer wrote an Apex class to make several callouts to an external system. If the URLs used in these callouts will change often, which feature should the developer use to minimize changes needed to the Apex class?

Options:

A.

Named Credentials

B.

Connected Apps

C.

Remote Site Settings

D.

Session Id

Question 39

The test method tests an Apex trigger that the developer knows will make a lot of queries when a lot of Accounts are simultaneously updated. The test method fails at Line 20 because of "too many SOQL queries." What is the correct way to fix this?

Java

Line 12: //Set accounts to be customers

Line 13: for(Account a : DataFactory.accounts)

Line 14: {

Line 15: a.Is_Customer__c = true;

Line 16: }

Line 17:

Line 18: update DataFactory.accounts;

Line 19:

Line 20: List acctsAfter = [SELECT Number_Of_Transfers__c FROM Account WHERE Id IN :DataFactory.accounts];

Options:

A.

Use Limits.getLimitQueries() to find the total number of queries that can be issued.

B.

Change the DataFactory class to create fewer Accounts so that the number of queries in the trigger is reduced.

C.

Add Test.startTest() before and add Test.stopTest() after both Line 7 and Line 20 of the code.

D.

Add Test.startTest() before and add Test.stopTest() after Line 18 of the code.

Question 40

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 do to address the issue?

Options:

A.

Turn off triggers, flows, and validations when running tests.

B.

Move the prerequisite reference data setup to the constructor for the test class.

C.

Move the prerequisite reference data setup to a @testSetup method in the test class.

D.

Move the prerequisite reference data setup to a TestDataFactory and call that from each test method.

Question 41

Universal Containers wants to notify an external system, in the event that an unhandled exception occurs, by publishing a custom event using Apex. What is the appropriate publish/subscribe logic to meet this requirement?

Options:

A.

Publish the error event using the EventBus.publish() method and have the external system subscribe to the event using CometD.

B.

Publish the error event using the addError() method and have the external system subscribe to the event using CometD.46

C.

Publish the error event using the addError() method and write a trigger to subscribe to the event and notif47y the external system.

D.

Have the external system subscribe to the event channel. No publishing is necessary.

Question 42

A Visualforce page loads slowly due to the large amount of data it displays. Which strategy can a developer use to improve the performance?

Options:

A.

Use the transient keyword for the List variables used in the custom controller.

B.

Use lazy loading to load the data on demand, instead of in the controller's constructor.

C.

Use JavaScript to move data processing to the browser instead of the controller.

D.

Use an in the page to load all of the data asynchronously.

Question 43

The Lightning Component allows users to click a button to save their changes and then redirects them to a different page. Currently, when the user hits the Save button, the records are getting saved, but they are not redirected. Which three techniques can a developer use to debug the JavaScript?1

Options:

A.

Use the browser's dev tools to debug the JavaScript.2

B.

Use Developer Console to view the debug log.34

C.

Use console.log() messages in the JavaScript.56

D.

Use Developer Console to view7 checkpoints.8

E.

Enable Debug Mode for Lightning components for the user.9

Question 44

Which three Visualforce components can be used to initiate Ajax behavior to perform partial page updates?

Options:

A.

B.

C.

D.

E.

Question 45

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

Options:

A.

Use controller.currentPage.setPage (MyTestPage);

B.

Use Test.setCurrentPage.MyTestPage;

C.

Use Test.setCurrentPage (Page.MyTestPage);

D.

Use Test.currentPage.getParameters.put (MyTestPage);

Question 46

A developer creates a lightning web component to allow a Contact to be quickly entered. However, error messages are not displayed.

HTML

Which component should the developer add to the form to display error messages?12

Options:

A.

lightning-messages

B.

lightning-error

C.

apex:messages

D.

aura:messages

Question 47

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

Java

global with sharing class MyRemoter {

public String accountName { get; set; }

public static Account account { get; set; }

public MyRemoter() {}

@RemoteAction

global static Account getAccount(String accountName) {

account = [SELECT Id, Name, NumberOfEmployees FROM Account WHERE Name = :accountName];

return account;

}

}

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

Options:

A.

Java

MyRemoter remote = new MyRemoter();

Account a = remote.getAccount('TestAccount');

System.assertEquals( 'TestAccount', a.Name );

B.

Java

MyRemoter remote = new MyRemoter('TestAccount');

Account a = remote.getAccount();

System.assertEquals( 'TestAccount' , a.Name );

C.

Java

Account a = controller.getAccount('TestAccount');

System.assertEquals( 'TestAccount', a.Name );

D.

Java

Account a = MyRemoter.getAccount('TestAccount');

System.assertEquals( 'TestAccount', a.Name );

Question 48

A developer is asked to find a way to store secret data with an ability to specify which profiles and users can access which secrets. What should be used to store this data?

Options:

A.

Static resources

B.

Custom metadata

C.

Custom settings

D.

System.Cookie class

Page: 1 / 16
Total 161 questions