Salesforce Platform Developer II - PDII Exam Practice Test
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?
Correct Answer: D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
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?
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?
Correct Answer: D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
Consider the queries in the options below and the following information:
* For these queries, assume that there are more than 200,000 Account records.
* These records include soft-deleted records in the Recycle Bin.
* There are two fields marked as External Id: Customer_Number__c and ERP_Key__c.
Which two queries are optimized for large data volumes?
* For these queries, assume that there are more than 200,000 Account records.
* These records include soft-deleted records in the Recycle Bin.
* There are two fields marked as External Id: Customer_Number__c and ERP_Key__c.
Which two queries are optimized for large data volumes?
Correct Answer: B,D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
Consider the following code snippet:
Java
HttpRequest req = new HttpRequest();
req.setEndpoint('https://TestEndpoint.example.com/some_path');
req.setMethod('GET');
Blob headerValue = Blob.valueOf('myUserName' + ':' + 'strongPassword'); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); Http http = new Http(); HTTPResponse res = http.send(req); Which two steps should the developer take to add flexibility to change the endpoint and credentials without needing to modify code?1
Java
HttpRequest req = new HttpRequest();
req.setEndpoint('https://TestEndpoint.example.com/some_path');
req.setMethod('GET');
Blob headerValue = Blob.valueOf('myUserName' + ':' + 'strongPassword'); String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); Http http = new Http(); HTTPResponse res = http.send(req); Which two steps should the developer take to add flexibility to change the endpoint and credentials without needing to modify code?1
Correct Answer: B,C
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
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<Account> 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?
Trigger:
Java
trigger AccountTrigger on Account (before insert) {
AuditAssigner.setAuditor(Trigger.new);
}
Apex Class:
Java
public class AuditAssigner {
public static void setAuditor(List<Account> 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?
Correct Answer: D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
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?
Correct Answer: D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
A developer wrote the following method to find all the test accounts in the org:
Java
public static Account[] searchTestAccounts() {
List<List<SObject>> searchList = [FIND 'test' IN ALL FIELDS RETURNING Account(Name)]; return (Account[]) searchList[0];
}
However, the test method below fails.
Java
@isTest
public static void testSearchTestAccounts() {
Account a = new Account(name='test');
insert a;
Account [] accounts = TestAccountFinder.searchTestAccounts();
System.assert(accounts.size() == 1);
}
What should be used to fix this failing test?
Java
public static Account[] searchTestAccounts() {
List<List<SObject>> searchList = [FIND 'test' IN ALL FIELDS RETURNING Account(Name)]; return (Account[]) searchList[0];
}
However, the test method below fails.
Java
@isTest
public static void testSearchTestAccounts() {
Account a = new Account(name='test');
insert a;
Account [] accounts = TestAccountFinder.searchTestAccounts();
System.assert(accounts.size() == 1);
}
What should be used to fix this failing test?
Correct Answer: B
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
A company has a Lightning page with many Lightning Components, some that cache reference data. It is reported that the page does not always show the most current reference data. What can a developer use to analyze and diagnose the problem in the Lightning page?
Correct Answer: C
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
A company wants to run different logic based on an Opportunity's record type. Which code segment handles this request and follows best practices?
Correct Answer: D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
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?
Correct Answer: A
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
Which method should be used to convert a Date to a String in the current user's locale?
Correct Answer: A
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
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
Correct Answer: D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
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. 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?16
Correct Answer: A,D
Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).