0% found this document useful (0 votes)
57 views36 pages

Set 7

The document outlines various scenarios and questions related to Salesforce development, including creating custom objects, triggers, and optimizing code for efficiency. It includes multiple-choice questions on best practices for Apex coding, Lightning components, and data management. The content is structured as a practice exam for Salesforce Certified Platform Developer II certification.

Uploaded by

dholu sk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views36 pages

Set 7

The document outlines various scenarios and questions related to Salesforce development, including creating custom objects, triggers, and optimizing code for efficiency. It includes multiple-choice questions on best practices for Apex coding, Lightning components, and data management. The content is structured as a practice exam for Salesforce Certified Platform Developer II certification.

Uploaded by

dholu sk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

—=alesSTorce weartirieda Fiatrorim weveloper L1 - MuUltipie .

nojce

Time= Remaining: 01:31:40 m

1 of 62. The Salesforce admin at Cloud Kicks created a custom object


called region= to store all postal zip codes in the United States and the
_loud Kicks sales region the zip code belongs to.

Object Name:
Region<

Fields:
zip codea o (Text)
Region Name < (Text)

Cloud Kicks wants a trigger on the Lead to populate the Region based on
the Lead's zip code.

Which code segment is the most efficient way to fulfill this request?

A SetcsScrings zips = new Set<String>();


for{liemmag 1 : Trigger.new)
ifi(l.PostalCedes = Mulli) |

zipa.add(l.PogstalCode) ;
A.@Q set«<String> zip2 = new Sec<String>();
for(Lead 1 : Trigger.new)
if(l.PostalCeode != Null) {
zips.add(l.PostalCode) ;

List<Region__c> regicons = [SELECT Zip Ccde¢, Reglion Name <


FROM Region_c© WHERE Zip Code_c IN :zips];

Map<Stxring, tring> zipMap = new Map<String, String>():;

for (Regaion__ ¢ r :regicens) |


zipMap.put (r.Zip Code ¢, r.Region
Name ¢);

for(Lead 1 : Trigger.new) {

if(l.PostalCode != Null) {
l1.Regicon¢ = zipMap.get (l.PostalCode);
}
}

9-() for(Lead 1 : Triggerx.new) {


Region_¢ reg = ([SELECT Region Name ¢ FROM Region__c©
WHERE Zip Code ¢ = :l.PcstalCecde];
l.Region_< = reg.Region
Name ¢£;
}

C-() Set<String> zips = new Sect<String>|();

Salesforce Certified Platformm Developer II - Multiple Choice

Time Remaining: 01:31:000

2 of 62. Part of a custom Lightning component displays the total number


of Opportunities in the org, which are in the millions. The Lightning
component uses an Apex method to get the data it needs.

What is the optimal way for a developer to get the total number of
Opportunities for the Lightning component?

A. () sum() SOQL aggregate query on the Opportunity object


B.@ COUNT 1) SOQL aggregate query on the Opportunity object
C. O SOQL for loop that counts the number of Opportunities records
D. O Apex batch job that counts the number of Opportunity records

D Mark this item for later review.

Provide question feedback here (optional):

[
Salesforce Certified Platformm Developer II - Multiple Cholice

Time Remaining: 01:30:33 m

3 of 62. An Apex trigger creates an crder< record every time an


Opportunity is won by a Sales Rep. Recently the trigger is creating two
orders.

What is the optimal technique for a developer to troubleshoot this?

A.() Setup debug logging for every Sales Rep, then monitor the logs for errors and
exceptions.
B. O Disable all flows, and then re-enable them one at at time to see which one causes the
error,
Cs O Run the Apex Test Classes for the Apex trigger to ensure the code still has sufficient
code coverage.
D@ Add system.debug() statements to the code and use the Developer Console logs to
trace the code,

D Mark this item for later review.

Provide question feedback here (optional):

Salesforce Certified Platformm Developer II - Multiple Cholice

Time Remaining: 01:30:24 m

4 of 62. Refer to the code snippet below:

public static void updatecCreditMemo (String customerId, Decimal


newamount) {
List<Credit_Memo__c¢> toUpdate = new List<Credit Memo__c>():;
for (Credit_Memo¢ creditMemo : [Select Id, Name, Amount__c
FROM Credit Memo_ ¢ WHERE Customer
Id ¢ = :customerId LIMIT
S501) {
creditMemo .Amount ¢ = newAmount;
toUpdate.add (creditMemo) ;
}
Databass.update (toUpdate, fals=) ;

A custom object called credit Memo < exists in a Salesforce environment.


Ac nart nnf a naw faatiire davalanmant that ratricevec and maninuilataac thia
ype Or recora, tne aeveioper neeas to ensure race conaitions are
prevented when a set of records are modified within an Apex transaction.

In the preceding Apex code, how can the developer alter the query
statement to use SOQL features to prevent race conditions within a
transaction?

A.(:) [Select Id, Name, Amcunt__ ¢ FROM Credit_Memc__ ¢ WHERE Customer_Id_c =


tcuscomerId LIMIT SO0 FOR REFERENCE]
B.(:) [Select 1Id, Name, Amount_¢ FROM Credit_Memo¢ WHERE Customer
Id c =
tcustomerlId USING SCOPE LIMIT 50)
C (Select 1d, Name, Amocunt__ ¢ FROM Credit_Memc¢ WHERE Custcomer_
Id ¢C =
tcustomerlId LIMIT SO FOR UPDATE]
D.O (Select 1Id, Name, Amount__ ¢ FROM Credit_Memc_¢ WHERE Customexr_ Id_C =
cscustomerld LIMIT SO0 FOR VIEW]

O Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

Salesforce Certified Platformm Developer II - Multiple Choice

Time Remaining: 01:30:14 m

5 of 62. Refer to the following code snippet:

public class lLeadController |


public static List<lead> getFetchleadlist(String searchTerm, Decimal aRevenue) {
String safeTerm = "'3'+sesarchTerm.escapeSingleQuote()+"3!
return |
SELECT Name, Company, AnnuallRevenue
FROM Lead
WEERE AnnualRevenue 5>= :aReyvenue
AND Company LIKE :safeTexrm;
LIMIT 20

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

Choose 3 answers
A. O Implement the withour sharing keyword in the class declaration.
B. Use the WITH SECURITY_ENFORCED clause within the SOQL query.
C. Annotate the Apex method with GauraEnabled(Cacheable=trus).
D. Implement the with sharing keyword in the class declaration.
E. () Annotate the Apex method with ZauraZnabled.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

OIS SIVIVLE WWEITIULNiIESW MmMiQuv N VEVEIVED 42 7 MU aiwwive

Time Remaining: 01:30:03@

6 of 62. A company uses Salesforce to sell products to customers. They


also have an external product information management (PIM) system that
is the system of record for products.

A developer received these requirements:


e Whenever a product is created or updated in the PIM, a product must
be created or updated as a Product2 record in Salesforce and a
PricebookEntry record must be created or updated automatically by
Salesforce.
« The PricebookEntry should be created in a Pricebook2 that is specified
in a custom setting.

What should the developer use to satisfy these requirements?

A, O Event Monitoring
8.@ Custom Apex REST
e O SObject Tree REST
0.O Invocable Action
J Ol OZ. LOlNisider uie Apex Clidass PDelow Liial dgelines a emmoteAcCLIon useua

on a Visualforce search page.

global with sharing class MyRemoter ({


public String accountName { get; set; }
public static Account account { get; set; }
public MyRemcter() {}

@RemcocteAction
global static Account getAccount (String accountName) ({
account = [SELECT Id, Name, NumberOfEmplovees
FROM Account WHERE Name = :accountName]:
retuxrn account;

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

A.(:).Account a = controller.getAccount('TestAccount'):
Sysrem.assercEquals( 'TescliAccount', a.Name );

B. Account a = MyRemoter.getAccount ('TestAccount'):


System.asgsertEquals( 'TestiAccount', a.Name );

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:29:49@

8 of 62. 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?

A. O Use the sLabel global value provider.


B. O Create a Hierarchical custom setting to store user preferences.

C.@ Use the sLocale value provider to retrieve the user preferences.
D. O Use the $U=z=x global variable to retrieve the user preferences,

D Mark this item for later review.


Salesforce Certified Platformm Developer II - Multiple Choice

Time Remaining: 01:29:45 m

9 of 62. A developer is tasked with ensuring that email addresses entered


into the system for Contacts and for a custom object called
Survey Response < do not belong to a list of blocked domains.

The list of blocked domains is stored Iin a custom object for ease of
maintenance by users. The survey Response ¢ object is populated via a
custom Visualforce page.

What is the optimal way to implement this?

A Implement the logic in a helper class that is called by an Apex trigger on Contact and
from the custom Visualforce page controller.
B.O Implement the logic in validation rules on the Contact and the Survey_Response_¢
objects.
Ca O Implement the logic in the custom Visualforce page controller and call that method
from an Apex trigger on Contact.
D. O Implement the logic in an Apex trigger on Contact and also implement the logic within
the custom Visualforce page controller.

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:29:41 m

10 of 62. A developer created an Opportunity trigger that updates the account rating when an
associated opportunity is considered high value. Current criteria for an opportunity to be considered
high value is an amount greater than or equal to $1,000,000. However, this criteria value can
change over time.

There is a new requirement to also display high value opportunities in a Lightning web component.

wWhich two actions should the developer take to meet these business requirements, and also prevent
the business logic that obtains the high value opportunities from being repeated in more than one
place?

Choose 2 answers
A Create a helper class that fetches the high value opportunities.
B. D Leave the business logic code inside the trigger for efficiency.
R D Call the trigger from the Lightning web component.
D. Use custom metadata to hold the high value amount,

D Mark this item for later review.


Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:29:37 m

11 of 62. A large company uses Salesforce across several departments. Each department has its
own Salesforce Administrator. It was agreed that each Administrator would have their own sandbox
in which to test changes.

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

Which two statements are true regarding these issues and resolution?

Choose 2 answers
A (") The administrators are deploying their own Change Sets over each other,
thus replacing entire Page Layouts in production.
B. M A sandbox should be created to use as a unified testing environment instead
of deploying Change Sets directly to production.
e Page Layouts should never be deployed via Change Sets, as this causes
Field-Level Security to be reset and fields to disappear.
D. O The administrators are deploying their own Change Sets, thus deleting each
other's fields from the objects in production.

() Mark this item for later review.

12 of 62. A developer is building a Lightning web component that retrieves


data from Salesforce and assigns it to the record property.

impert { LightningElement, api, wire } from 'lwec':;


impert { getRecord } from 'lightning/uiRecordApi':;

export default class Record extends LightningElement ({


@api fields:;
@api recordId;
recorxrd:;

What must be done in the component to get the data from Salesforce?

A.O Add the following code above recoxd;


Bwire (getRecord, { recordld: 'SrecordId' })
Get the fields in renderedCalliback () and assign them 1o record.

B. O Add the following code above record;


gapi (getRecord, { recordld: 'Srecordld' ))
Get the fields in render=dCaliback () and assign them to record,

0 Add the following code above recoxd:;


guire (getRecord, { recordlId: 'srecordId', fields: '§fields' })

M N AAA tha fallawinnm rada ahmura oo - P


Salesforce Certified Platform Developer II - Multiple Cholice

Time Remaining: 01:29:23 m

13 of 62. A developer is writing a Jest test for a Lightning web component


that conditionally displays child components based on a user’s checkbox
selections.

What should the developer do to properly test that the correct components
display and hide for each scenario?

A, O Add a teardown block to reset the DOM after each test.


B. O Reset the DOM after each test with the afterEach () method.
C. O Create a new -adom instance for each test,
D@ Create a new describe block for each test.

[:] Mark this item for later review.

Provide question feedback here (optional):

Salesforce Certified Platformm Developer II - Multiple Choice

Time Remaining: 01:29:17 m

14 of 62. A developer sees test fallures Iin 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?

A, O Ensure that Disable Parallel Apex Testing is unchecked.

B. O Ensure the Apex classes are on the same API version.

C@ Ensure the sandbox is on the same release as production.


D. O Ensure test classes are using SeeillData = true.

D Mark this item for later review.

Provide question feedback here (optional):

[ Please Provide Feedback here...


Salesforce Certified Platform Developer II - Multiple Cholice

Time Remaining: 01:29:13@

15 of 62. 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?

A, O Use a Database Savepoint method with a try-catch block.

B.@ Use sectSavePoint () and xollback() with a try-catch block.

2t O Use the Databas= Del=t= method if the Contact insertion fails.

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

D Mark this item for later review.

Provide question feedback here (optional):

[ Please Provide Feedback here...

Salesforce Certified Platformm Developer II - Multiple Choice

Time Remaining: 01:29:09 m

16 of 62. 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 FiracDayOrweek field from the Locale for the current user.
B. Use UserIinfo.ge=tlocals= () in the component.

€ O Import the Esaleaforce/i112n module and use


the firscDayOrWesk internationalization property.
D. O Use a custom metadata type to store key/value pairs.

O Mark this item for later review.

Provide question feedback here (optional):


Salesforce Certified Platform Developer II - Multiple Choice

m |
Time Remaining: 01:29:07 m

17 of 62. Which code snippet processes records in the most memory


efficient manner, avoiding governor limits such as "Apex heap size too
large"?

A.(:):ror(ODportunltv opp: ([SELECT Id, Amount from Opportunity)) (


// perform cperation here
}
B.(:) List<0Opportunity> opportunitics = Datesbase.quersy('SELECT Id, Amount £from
Opportunicty'):
for(Opportunity opp: opportunitaies)
// perform operation here
>
C.O List<Opportunity> opportunities = [SELECT Id, Amount from Opportunityl:
for (Opportunity Oopp: oppertunities) (
// perform operation here
s
D Map<IlId, Cpportunity> oppcrtunities new Map<Ild, Cpportunity>({[(SELECT Id,
Amount from Cpportunityl):
for(Id oppld: cocpportunities.keySect()) {
// perform operation here
¥

Salesforce Certified Platform Developer II - Multiple Choice

m!
Time Remaining: 01:29:01 m

18 of 62. Universal Containers decided to use Salesforce to manage a new


hire interview process. A custom object called Candidate was created with
organization-wide defaults set to Private. A lookup on the Candidate object
sets an employee as an Interviewer,

What should be used to automatically give Read access to the record when
the lookup field is set to the Interviewer user?

A, O The record can be shared using a sharing rule.


B. O The record can be shared using a permission set,
£ O The record cannot be shared with the current setup.
D@ The record can be shared using an Apex class.

O Mark this item for later review.

Provide question feedback here (optional):

[ Dlaaca Drnvida Faadhack hara


Salesforce Certified Platform Developer II - Multiple Choice

m |
Time Remaining: 01:28:57 m

19 of 62. Which statement is true regarding savepoints?

A Static variables are not reverted during a rollback.


B. O Reference to savepoints can cross trigger invocations.
e O Savepoints are not limited by DML statement governor limits.
D. O You can roll back to any savepoint variable created in any order.

C] Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

Salesforce Certified Platform Developer II - Multiple Choice

m |
Time Remaining: 01:28:540

20 of 62. A developer is writing code that requires making callouts to an


external web service.

Which scenario necessitates that the callout be made in an asynchronous


method?

A, O Over 10 callouts will be made in a single transaction.


B. O The callout could take longer than 60 seconds to complete.
Cs O The callouts will be made using the REST API.
D@ The callouts will be made in an Apex trigger.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


Salesforce Certified Platform Developer II - Multiple Choice

m |
Time Remaining: 01:28:51 m

21 of 62. 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. O 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. O Move the prerequisite reference data setup to a @testSetup method in the test class.
D. o Move the prerequisite reference data setup to the constructor for the test class.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

Salesforce Certified Platform Developer II - Multiple Choice

m |
Time Remaining: 01:28:48 m

22 of 62. A developer built an Aura component for guests to self-register


upon arrival at a front desk kiosk. Now the developer needs to create a
component for the utility tray to alert users whenever a guest arrives at the
front desk.

Wwhat should be used?

A@ Application Event
B. O DML Operation

C.(O Component Event


D.O ChangelLog

D Mark this item for later review.

Provide question feedback here (optional):

[ Please Provide Feedback here...


Salesforce Certified Platform Developer II - Multiple Choice

m |
Time Remaining: 01:28:449 m

23 of 62. 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
A Flow Builder
B. D Apex invocable method
C. Apex trigger

D.D Remote action

D Mark this item for later review.

Provide question feedback here (optional):

Salesforce Certified Platform Developer II - Multiple Choice

m |
Time Remaining: 01:28:40@

24 of 62. 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?

A O The test class does not use the sessalllData=true annotation.


B. The test class does not retrieve the updated value from the database,
2, O The test class does not implement the Queueable interface.
D. O The test class does not use the Bulk API for loading test data.

D Mark this item for later review.

Provide question feedback here (optional):

[ Please Provide Feedback here...


25 of 62. Refer to the test method below:

@isTest
static void testIncrement() ¢
Account acct = new Account (Name = 'Test'):
acct.Number
Of Times Viewed < = 0;
insert acct:

AuditUtil.incrementViewed (acct.Id);
Account acctAfter = [SELECT Number
Of Times Viewed ¢ FROM
Account WHERE Id = :acct.Id][0]:

System.assertEguals
(1,
acctAfter.Number
Of Times Viewed c):
}

The test method calls an @future method that increments the


Number of Times Viewed ¢ value. The assertion is failing because the
Number of Times Viewed ¢ equals 0.

What is the optimal way to fix this?

The test method calls an efuture method that increments the


Number of Times Viewed < value. The assertion is failing because the
Number of Times Viewed ¢ equals O.

What is the optimal way to fix this?

A, O Change the assertion to System.assertEquals (0,


acctAfter.Number Of Times_ Viewed_c).
B. o Change the initialization to acct.Number_Cf
Times Viewed__c = 1,
C Add Teast.ztarcTeat () before and Test.2topTezt () after
AuditUctil.incrementViewed.
D.O Add Test.=starcTeat () before and Teszt.atopTesc () after i1nsert accr.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:28: 18@

26 of 62. A Visualforce page loads slowly due to the large amount of data
it displays.

Which strategy can a developer use to improve the performance?

A Use lazy loading to load the data on demand, instead of in the controller's constructor.
B. O Use the transient keyword for the List variables used in the custom controller.
C.(O) Use an <apex:actionPoller> in the page to load all of the data asynchronously.
D. O Use JavaScript to move data processing to the browser instead of the controller.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

27 of 62. A developer created a Lightning web component that allows users to input a text value
that Iis used to search for Accounts by calling an Apex method. The Apex method returns a list of
AccountWrappers and is called imperatively from a JavaScript event handler.

01l1:
02: public class AccountSearcher {
C3:

04z public static List<AccountWrapper> search{(String term) {


0S: Lisc<iccountWrapper> wrappers = getMartchingiAccountWrappers
(term);
06: return wrappers;
07: }
08:
Q9:
10: public class AccountiWrapper |
11: public Account { get: set: }
12: public Decimal matchProbabkility ( get; set; )
233 }
14: // «..0ther methodes, including getMatchingiccountiWrappers implementation...
31338 }

Which two changes should the developer make so the Apex method functions correctly?

Choose 2 answers
A Add GAuraEnabled to line 03,
B. Add GauraEnabled to lines 11 and 12,
o D Add GAuraEnabl=d to line 01.

D. D Add GauraEnabled to line 09.


Time Remaining: 01:27:55 @

28 of 62. 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?

A@ Use a hierarchy custom setting to skip executing the logic inside the trigger for the
user who loads the data.
B. O Add the Profile ID of the user who loads the data to the trigger, so the trigger will not
fire for this user.
C.O Add a validation rule to the Contract to prevent Contract creation by the user who
loads the data.
D. O Use a list custom setting to disable the trigger for the user who loads the data.

'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:46 @

29 of 62. 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?

A, O Use Limits class to stop entire process once governor limits are reached.
8.@ Use Queueable Apex to chain the jobs to run sequentially.
82 O Use multiple Efuture methods for each process and callout.
D. O Use Apex Scheduler to schedule each process.

D Mark this item for later review.

Provide question feedback here (optional):


'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:41 m

30 of 62. 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?

A. O Use an Apex trigger with Batch Apex.

B.@ Use an Email Alert with Flow Builder.


e O Use MasaEmailMeasage () with an Apex trigger.

D. O Use SingleEmailMess=zage () with an Apex trigger.

D Mark this item for later review.

Provide question feedback here (optional):

[ Mlameca Memurid s Canmndlhiacls lhAava

'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:38 m

31 of 62. 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 3 answers
A. D Use the final keyword in the controller for variables that will not change.
B. Use the transient keyword in the Apex controller for variables that do not
maintain state.
C. Use filters and pagination to reduce the amount of data.
D. O Use the private keyword in the controller for variables,
E. Refine any SOQL queries to return only data relevant to the page.

D Mark this item for later review.


'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:35@

32 of 62. Consider the queries in the options below and the following information:
e For these queries, assume that there are more than 200,000 Account records.
e These records include soft-deleted records; that is, deleted records that are still in the Recycle
Bin.
e There are two fields that are marked as External Id on the Account., These fields are
Customer Number < and ERP_Key
<.

Which two queries are optimized for large data volumes?

Choose 2 answers
A SELECT Id FROM Account WHERE Id IN :alistVariable
B.(C) SELECT Id FROM Account WHERE Name != NULL
C. SELECT Id FRCM Account WHERE Name != '' AND Customer Number c =
'Valuel'
D.D SELECT Id FROM Account WHERE Name != '' AND IsDeleted = false

O Mark this item for later review.

'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:30@

33 of 62. A developer is developing a reusable Aura component that will


reside on an sObject Lightning page with the following HTML snippet:

<aura:compeonent
implements="force:hasRecordld, flexipage:availableForAllPageTyps
<div>Hello!</div>
</aura:component>

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

A-O Create a design attribute and configure via App Builder.


B.@ Add force:nasSobjectName to the implements attribute.
C. O Use the get30bi=ctTyp=() method in an Apex class.
D.() Setthe sObject type as a component attribute.
34 of 62. Given the following code:

for ( Contact ¢ : [SELECT Id, LastName FROM Contact WHERE


CreatedDate = TODAY] )

{
Account a = [SELECT Id, Name FROM Account WHERE CreatedDate
= TODAY LIMIT 5):
c.AccountlId = a.Id:;
update c;

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

A, O System.QueryException: Too many DML Statement errors on Contact


B.@ System.QueryException: List has more than one row for Assignment on Account
E: O System.LimitException: Too many SOQL Queries on Account
D.O System.LimitException: Too many SOQL Queries on Contact

O Mark this item for later review.

Provide question feedback here (optional):

'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:13m

35 of 62. A developer creates a Lightning web component to allow a


Contact to be quickly entered. However, error messages are not displayed.

<template>
<lightning-record-edit-form
object—-api-name="Contact">
<lightning-input-field field-name="FirstName">
</lightning-input-field>
<lightning-input-field fisld-name="LastName">
</lightning-input-field>
<lightning-input-field field-name="Email"></lightning-
input-field>
<lightning-button type="submit"
name="submit"
label="Create Contact">
</lightning-button>

B. O aura:messages

C.O lightning-error

D@ lightning-meszsages

O Mark this item for later review,

Provide question feedback here (optional):

Please Provide Feedback here...

‘-j"“"' t Y","'

'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:07m

36 of 62. Which tag should a developer use to display different text while
an <apex:commandButton> IS processing an action?

A, O <apex:pageMesgs=zages>

B.O <apex:actionPoller>

C.O <apex:acrtionSupporct>

D@ <apex:acticonStatus>

C] Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:27:04 m

37 of 62. A developer is responsible for formulating the deployment


process for a Salesforce project. The project follows a source-driven
development approach, and the developer wants to ensure efficient
deployment and version control of the metadata changes.

Which tool or mechanism should be utilized for managing the source-driven


deployment process?

A. O Change Sets

B.@ Salesforce CLI with Salesforce DX


C. O Change Sets
D.O Data Loader

D Mark this item for later review.

Provide question feedback here (optional):

'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:26:59@

38 of 62. 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?

A@ Custom metadata
B. () Custom setting
C. O Custom variable

D.O Custom object

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


'/
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:26:54 m

39 of 62. A developer wants to write a generic Apex method that will


compare the Salesforce Name field between any two object records. For
example, to compare the Name field of an Account and an Opportunity; or
the Name of an Account and a Contact.

Assuming the Name field exists, how should the developer do this?

A@ Cast each object into an sObject and use 2Coject.get ( ‘Name’ ) to compare the Name
fields.
B. O Invoke a Schema.describe () function to compare the values of each Name field.
C. O Use the Salesforce Metadata API to extract the value of each object and compare the
Name fields.
D. O Use a String.replac= () method to parse the contents of each Name field and then
compare the results.

CJ Mark this item for later review.

Provide question feedback here (optional):

Time Remaining: 01:26:42m

40 of 62. Refer to the code:

01 <€!=-= Lightning Web Component HEIML file —-->


02
03 <template>
o4 <lightning-buttcon label-="Call server" onclick-{handleClick}></lightning~button>
0S5 </rtemplate>

01 // Laightning Web Component JS file


02
03 import {LightningElement) from 'lwc';
04 import serverEche from '@salesforce/apex/SimpleServerSideController.sarverEche';
oS
D€ export default class Hellcocweorld extends LightningElement {
07 firstName = ‘woxrld':;
08 handleClick() {
09 serverEcho({ firsctName: this.firsctName })
10 .then((resulc) => {
11 alerc('From server: ' <+ result):;

12 1)
13 .catch( (exrrorxr) => |{
14 conscle.erxor{exrxror):
1S }):
14 conacle.erxor{exror):
18 ¥):
16 }

27 )

01 // Apex Controller feor Lightning Component


02
03 public with sharing class SimpleServerSideController |
24 @AuraEnabled
0S5 public static String serverEcho (sObject firstName) (
o6 tring firstNameStr = (String)firstName.get('firstName'):
0 return ('Helle from the server, ' + firsctNameSty):;
o8 }
0 )

Given the code above, which two changes need to be made in the Apex Controller for the code to
work?

Choose 2 answers
A Change the argument in the Apex Controller line 05 from sCbiect to S=ring.
B. Remove line 06 from the Apex Controller and instead use rirsctName in the
return on line 07,
C. O Change the method signature to be globkal =tatic, notpublic =tatic.
D. D Annotate the entire class as GAuraEnabled Iinstead of just the single method.

~ Admals dlala 1Idancn fau labuu vsavdaii,

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:26:35 m

41 of 62. A company uses Opportunities 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?

A, O Use Sysctem.anguesuaJJok() to invoke a Queus=abkl= class.


B. o Use Database.executeBatch() to invoke a Queuecable class.

C.@ Use Database.executeBatch() to invoke a Database.Batchable class.

D. O Use System. scheduleTok() to schedule a Databas=e 2chedul=sble= class.


Time Remaining: 01:26:27 1"

42 of 62. An org has an existing process, built using Process Builder, on


Opportunity that sets a custom field, CommissionBaseamount <, when an
Opportunity is edited and the Opportunity's Amount changes.

A developer recently deployed an Opportunity before update trigger that


uses the commissionBaseAmount< and complex logic to calculate a value
for a custom field, commissionamount <, when an Opportunity stage
changes to Closed/Won.

Users report that when they change the Opportunity to Closed/Won and
also change the Amount during the same save,
the commissionamount¢ is incorrect.

Which action should the developer take to correct this problem?

A Call the process from the trigger.


B. O Call the trigger from the process.
C@ Replace the process with a Fast Field Update record-trigger flow.

O Mark this item for later review.

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:26:23 m

43 of 62. 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?

A An arter update trigger on Case that creates the Engineering Review record and
inserts it
B. Abefor= ups==rrt trigger on Case that creates the Engineering Review record and
inserts it
42 o An after upaser: trigger on Case that creates the Engineering Review record and
inserts it
D.O A pefore update trigger on Case that creates the Engineering Review record and
inserts it

D Mark this item for later review.

Provide question feedback here (optional):


Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:26:19 m

44 of 62. A company wants to incorporate a third-party web service to set


the Address fields when an Account is inserted, if they have not already
been set.

What is the optimal way to achieve this?

A, O Create a Before Save Flow, execute a Queueable job from it, and make a callout from
the Queueable job.
B. Create an Apex class, execute a Future method from it, and make a callout from the
Future method.
C Create an Apex trigger, execute a Queueable job from it, and make a callout from the
Queueable job.
D. Create an Apex class, execute a Batch Apex job from it, and make a callout from the
Batch Apex job.

D Mark this item for later review.

Provide question feedback here (optional):

[ Ml e Menncs'td e Pandh
s Al e -

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:26:15 m

45 of 62. A developer is tasked with creating a Lightning web component that is responsive on
various devices,

which two components should help accomplish this goal?

Choose 2 answers
A.D lightning~-layocout-item

B. D lightning-input-location

C lightning-navigation

D. lightning~layout

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


46 of 62. Universal Containers wants to use a Customer Community with
Customer Community Plus licenses to allow their customers access to track
how many containers they have rented and when they are due back.
Universal Containers uses a Private sharing model for External users.

Many of their customers are multi-national corporations with complex


Account hierarchies. Each account on the hierarchy represents a
department within the same business.

One of the requirements is to allow certain community users within the


same Account hierarchy to see several departments' containers, based on a
custom junction object that relates the Contact to the various Account
records that represent the departments.

Which solution solves these requirements?

A An Apex trigger that creates Apex managed sharing records based on the junction
object’'s relationships
8. O A Lightning web component on the Community Home Page that uses Lightning Data
Services,
) O A Visualforce page that uses a custom controller that specifies withour szharing to
expose the records
D. O A custom list view on the junction object with filters that will show the proper records
based on owner

‘4
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:26:04 m

47 of 62. Universal Containers is using a custom Salesforce application to


manage customer support cases. The support team needs to collaborate
with external partners to resolve certain cases. However, they want to
control the visibility and access to the cases shared with the external
partners.

Which Salesforce feature can help achieve this requirement?

A, O Apex managed sharing

B.O Role hierarchy


i O Criteria-based sharing rules
D@ Sharing sets

O Mark this item for later review.

Provide question feedback here (optional):


‘4
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:25:59 m

48 of 62. An org records customer order information in a custom object,


order <, that has fields for the shipping address. A developer is tasked
with adding code to calculate shipping charges on an order, based on a flat
percentage rate associated with the region of the shipping address.

What should the developer use to store the rates by region, so that when
the changes are deployed to production no additional steps are needed for
the calculation to work?

A. O Custom object
8. o Custom list setting
C@ Custom metadata type
D. O Custom hierarchy setting

O Mark this item for later review.

‘4
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:25:55 m

49 of 62. 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?

A@ Replace custom settings with custom metadata.


B.O Replace custom settings with static resources.
C. O Set the setting type on the custom setting to List.

D. O Set the setting type on the custom setting to Hierarchy.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:25:500

50 of 62. A developer creates an application event that has triggered an


infinite loop.

What may have caused this problem?

A. O An event is fired 'ontouchend’' and is unhandled.


B. O The event has multiple handlers registered in the project,
C@ The event is fired from a custom renderer.
D. O The event handler calls a trigger.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

51 of 62. An Aura component has a section that displays some information


about an Account and it works well on the desktop, but users have to scroll
horizontally to see the description field output on their mobile devices and
tablets.

<lightning:layout multipleRows="false">
<lightning:laycutItem size="é">(!v.rec.Name)
</lightning:layoutItem>

<lightning:layocutltem size="6">{!v.rec.Description__
¢}
</lightning:layoutltem>
</lightning:layout>

How should a developer change the component to be responsive for mobile


and tablet devices?

A.@ <lightning:layout multipleRows="true">


<lightning:layoutlitem size="12" largeDeviceSize="¢g¢">{!v.rec.Nam=]}
</lightning:laycuctlitem>

<lightning:layoutltem 21ize="12" largeDeviceSize="g">


{!v.rec.Deascription__
¢}
</lightning:laycuctlItem>
</lightnaing: layout>
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:25:39 m

52 of 62. A developer created a class that implements the Queueable Interface, as follows:

public class without sgharing OrderQueueableJch implements Queusable |


public void execute (QueueableContext context) {
// implemeantacticn logic
Sysctenm.enqueueJob
(new FollowUpJdeb()):

As part of the deployment process, the developer is asked to create a corresponding test class.

which two actions should the developer take to successfully execute the test class?

Choose 2 answers
A, Implement se=AllData=trus to ensure the Queueable job is able to run in
bulk mode.
B. Ensure the running user of the test class has, at least, the Vview All
permission on the Order object,
P D Implement Tes: . isRunningTest () to prevent chaining jobs during test
execution.
D. Enclose System.engqueueJcobk (new OrderQueueableJob()) within
Test . svartTes=:r and Tesc. stopTesc ().

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:25:33 m

53 of 62. Which three actions must be completed in a Lightning web component for a JavaScript file
in a static resource to be loaded?

Choose 3 answers
A, D Append the static resource to the DOM.
B. D Reference the static resource in a <script> tag.
C Call 1loadScripz:.
D. Import the static resource.
E. Import a method from the platformResourcelLoader.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


Salesforce Certified Platform Developer II - Multiple Choice

|
m
Time Remaining: 01:25:28 m

54 of 62. A developer implemented a custom data table in a Lightning web


component with filter functionality. However, users are submitting support
tickets about long load times when the filters are changed. The component
uses an Apex method that is called to query for records based on the
selected filters.

What should the developer do to improve performance of the component?

A.@ Use =«t2corabl=() in the Apex method to store the response in the client-side cache.

B. O Return all records into a list when the component is created and filter the array in
JavaScript.
Ci O Use a selective SOQL query with a custom index.
D. O Use SOSL to query the records on filter change,

O Mark this item for later review.

Provide question feedback here (optional):


L .

Salesforce Certified Platform Developer II - Multiple Choice

|
m
Time Remaining: 01:25:19 m

55 of 62. Refer to the following code snippets:

MyOpportunities.js

import { LightningElement, api, wire ) from 'lwc';


import getOpportunities from
'@salesforce/apex/OpportunityController. findMyOpportunities':;

export default class MyOppertunities extends LightningElement ({


@Gapi usexrId:;
@Gwire (getOpportunities, {opplOwner: 'SuserId'})
opportunities;

OpportunityController.cls

public with sharing class OpportunityController {


A. O Edit the code to use the withour sharing keyword in the Apex class.
B. (O Ensure the OWD for the Opportunity object is Public.
C@ Use the Cacheable~true attribute in the Apex method.
D. O Use the Continuaticn=trru= attribute in the Apex method.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...


L

56 of 62. trigger AssignOwnerBSyRegicon on Account ( before insert, before update )


{
List<Account> accountlist = new List<Account>():
foxr( Account aniAccount : trigger.new )
{
Region___¢ theRegicn = |
SELECT Id, Name, Region_Manager¢
FROM Region__ ¢
WHERE Name = :anAccount.Region_Name_¢
]?
anAccount.Ownerld = theRegion.Region_Manager_
¢

accountlList.add{( anAccount ):;

update accountlisct;

Consider the above trigger intended to assign the Account to the manager of the Account's region.

which two changes should a developer make in this trigger to adhere to best practices?

Choose 2 answers
A, D Use a Map to cache the results of the Region__c query by Id.
B. Move the Region__c query to outside the loop.
o Remove the last line updating accountlLis=r as it is not needed.
D.C] Use a Map accountMap instead of List accountList.
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:25:080

57 of 62. 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?

A, O Session Id
B. O Connected Apps
C@ Named Credentials
D. O Remote Site Settings

O Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

58 of 62. Consider the following code snippet:

01 public class with sharing AccountsController{


02
03 GAuraEnabled
04 pubkblic List<Accounts> getAllAccounts
() {
0S5 return [Select Id, Name, Industry FRCM Account]:;
06 }
07
08 3}

As part of the deployment cycle, a developer creates the following test


class:

01 private class with sharing AccountsControllexr


Test{
02
03 GTestSetup
04 private static wvoid makeData
() {
0S5 User userl = [Select Id FROM User WHERE
Profile.Name = 'System Administrator' and isActive = true LIMIT
1 ]:
06 User user2 = [Select Id FRCOM User WHERE
TMawmdEa T -~ AT == v - — L e e e e B | L JF N | — e ] LR WP I T S NS — L L T o~ oo 1
When the test class runs, the assertion fails.

Which change should the developer implement in the Apex test method to
ensure the test method executes successfully?

A.@ Add System.runis (Uzerxr) to line 14 and enclose line 15 within Tesc.z2tarctTesz () and
Test.stopTest().
B. o Add @IzTest (22=2AllData=true) to line 12 and enclose lines 15 and 16 within
Tesat.startTeat() and Test.stopTesc
().
C. O Query the Standard User into memory and enclose lines 15 and 16 within the
System.runhz (uzer) method.
D. O Query the Administrator user into memory and enclose lines 15 and 16 within the
Sys=tem.runis
(u==xr) method.

D Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:24:50 m

59 of 62. Consider the following code snippet:

HtTtpRegquest reg = new HTUtpReguest():;

reg.setEndpoint(‘https://TestEndpeoint.example.com/some_path');
reg.secMachod('GET") ;
Blob headexrxValue = Blob.valueOf ('myUserName' + ':' + 'sctrongPassword'):
Scring authorizationHeader = '"BASIC ' + EncodingUrtil.basseédEncode (headexValue)
reg.sectHeader ('Autherization', authorizationHeader):
Hetp hettp = new Hettp():
HITPResponse resa = http.send({req):

Which two steps should the developer take to add flexibility to change the endpoint and credentials
without needing to modify code?

Choose 2 answers
A. C] Use reg.sectEndpoint (Label .endPointURL) ;.

B. Use reg.setEndpoint('callcutr:endPoint_NC'): within the callout


request,
C: D Store the URL of the endpoint in a custom Label named =ndPointURL.

D. Create a Named Credential, end®focint_NC, to store the endpoint and


credentials.
Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:24:44@

60 of 62. Universal Containers has an Apex trigger on Account that creates


an Account Plan record when an Account is marked as a Customer.

Recently a record-triggered flow was added so that whenever an Account is


marked as a Customer, a 'Customer Since' date field is updated with
today's date. Since the addition of the flow, two Account Plan records are
created whenever the Account is marked as a Customer.

What might cause this to happen?

A. O The flow is configured to use an 'Update Records' element.


B. O The flow is configured to evaluate when a record is created and every time it is edited.
C.@ The Apex trigger does not use a static variable to ensure it only fires once.

D. O The Apex trigger is not bulk safe and calls insert inside of a for loop.

D Mark this item for later review.

Salesforce Certified Platform Developer II - Multiple Choice

Time Remaining: 01:24:38@

61 of 62. After a platform event is defined Iin a Salesforce org, events can
be published via which mechanism?

A, O Internal Apps can use outbound messages.

B. O Internal Apps can use entitlement processes,


C O External Apps require the standard Streaming API.
D@ External Apps use an API to publish event messages.

O Mark this item for later review.

Provide question feedback here (optional):

Please Provide Feedback here...

You might also like