Exam Questions and Answers for PDI Study Guide Questions and Answers!
Platform Developer I (PDI) Certification Sample Questions and Practice Exam
NEW QUESTION # 26
Which annotation exposes an Apex class as a RESTful web service?
- A.

- B.

- C.

- D.

Answer: A
NEW QUESTION # 27
What should a developer use to fix a Lightning web component bug in a sandbox?
- A. VS Code
- B. Force.com IDE
- C. Developer Console
- D. Execute Anonumous
Answer: A
NEW QUESTION # 28
What is a benefit of developing applications in a multi-tenant environment?
- A. Enforced best practices for development
- B. Access to predefined computing resources
- C. Unlimited processing power and memory
- D. Default out-of-the-box configuration
Answer: D
NEW QUESTION # 29
A developer needs to allow users to complete a form on an Account record that will create record for a custom object.
The form needs to display different fields depending on the user's job role. The functionality should only be available to a small group of users.
Which three things should the developer do to satisfy these requirements?
Choose 3 answers
- A. Add a Dynamic Action to the Users' assigned Page Layouts,
- B. Add a Dynamic Action to the Account Record Page.
- C. Create a Lightning web component,
- D. Create a Dynamic Form.
- E. Create a Custom Permission for the users.
Answer: C,D,E
Explanation:
Option A: Create a Custom Permission for the users.
True.
Custom Permissions can be used to control access to specific functionality.
By assigning the custom permission to a small group of users, the form's availability is restricted.
A Lightning Web Component can be built to display the form and handle dynamic field display based on the user's job role.
Dynamic Forms allow fields to be displayed or hidden based on criteria, such as user role.
Dynamic Actions control button visibility, not form fields.
Option D: Add a Dynamic Action to the Users' assigned Page Layouts.
Not Necessary.
Page Layouts are less flexible for controlling field-level visibility based on user role compared to Dynamic Forms.
Conclusion:
The three things the developer should do are A, B, and E.
Reference:
Custom Permissions
Option B: Create a Lightning web component.
True.
Lightning Web Components
Option E: Create a Dynamic Form.
True.
Dynamic Forms
Option C: Add a Dynamic Action to the Account Record Page.
Not Directly Applicable.
NEW QUESTION # 30
A developer needs to make a custom Lightning Web Component available in the Salesforce Classic user interface Which approach can be used to accomplish this?
- A. Embed the Lightning Web Component is a Visualforce Component and add directly to the page layout.
- B. Use a Visualforce page with a custom controller to invoke the Lightning Web Component using a call to an Apex method.
- C. Use the Lightning Out JavaScript library to embed the Lightning Web Component in a Visualforce page and add to the page layout.
- D. Wrap the Lightning Web Component in an Aura Component and surface the Aura Component as a Visualforce tab.
Answer: C
NEW QUESTION # 31
Consider the following code snippet:
Given the multi-tenant architecture of the Salesforce platform, what is a best practice a developer should implement and ensure successful execution of the method?
- A. Avoid performing queries inside for loops.
- B. Avoid using variables as query filters.
- C. Avoid executing queries without a limit clause.
- D. Avoid returning an empty List of records.
Answer: A
Explanation:
* Performing queries inside a loop can lead togovernor limit exceptionsdue to too many SOQL queries in a single transaction. Instead, perform queries outside loops.
:Best Practices for Avoiding Governor Limits
NEW QUESTION # 32
A developer needs to allow users to complete a form on an Account record that will create a record for a custom object.
The form needs to display different fields depending on the user's job role, The functionality should only be available to a small group of users.
Which three things should the developer do to satisfy these requirements?
Choose 3 answers
- A. Create a Dynamic Form.
- B. Add a Dynamic Action to the Account Record Page.
- C. Create a Custom Permission for the users.
- D. Create a Lightning wed component.
- E. Add a Dynamic Action to the Users' assigned Page Layouts.
Answer: C,D,E
Explanation:
* Custom Permission:
* Ensures that only the small group of users has access to this functionality.
* Dynamic Action:
* Allows displaying different fields depending on the user's role directly on the Account Record Page.
* Why Not A or C:
* Dynamic Forms are not used to create records for custom objects in this context.
* A Lightning Web Component is unnecessary when Dynamic Actions can be used.
* Dynamic Actions: https://help.salesforce.com/s/articleView?id=sf.dynamic_actions.htm
* Custom Permissions: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode
/apex_classes_perms_custom.htm
References:
NEW QUESTION # 33
A Developer Edition org has five existing accounts. A developer wants to add 10 more accounts for testing purposes.
The following code is executed in the Developer Console using the Execute Anonymous window:
How many total accounts will be in the org after this code is executed?
- A. 0
- B. 1
- C. 2
- D. 3
Answer: D
Explanation:
* The code snippet in question creates and inserts an account namedMyAccountand then initializes a loop to add additional accounts.
* The loop runs fromx = 1and continues adding accounts untilx < 10.
* Since the conditionx++is post-increment, the loop runs exactly 10 times, creating and adding 10 new accounts to thenewAccountslist.
* At the end, theinsertDML statement persists these 10 new accounts, along with the already existing account (MyAccount).
Total accounts in the org:
* Existing accounts = 5
* New accounts added = 10
* Total = 15
:
Salesforce Apex Developer Guide
Salesforce SOQL & SOSL Reference
NEW QUESTION # 34
What is the data type returned by the following SOSL search? {FIND 'Acme*' in name fields returning account,opportunity};
- A. List<List<sObject>>
- B. Map<Id,sObject>
- C. List<List<Account>,List<Opportunity>
- D. Map<sObject,sObject>
Answer: A
NEW QUESTION # 35
The orderHelper class is a utility class that contains business logic for processing orders. Consider the following code snippet:
A developer needs to create a constant named delivery_multiplier with a value of 4.15. The value of the constant should not change at any time in the code.
How should the developer declare the delivery multiplier constant to meet the business objectives?
- A. static decimal DELIVERY_MULTIPLIER = 4.15;
- B. decimal DELIVERY_MULTIPLIER = 4.15;
- C. static final decimal DELIVERY_MULTIPLIER = 4.15;
- D. constant decimal DELIVERY_MULTIPLIER = 4.15;
Answer: C
NEW QUESTION # 36
A developer considers the following snippet of code:
Based an this code, what is the value of x?
- A. 0
- B. 1
- C. 2
- D. 3
Answer: C
Explanation:
* TheBoolean isOKvariable is declared but not initialized, meaning its value isnullby default in Apex.
* The code evaluates theif-elseconditions in sequence:
* Condition 1:isOK == false && theString == 'Hello'
* isOKisnull, so this evaluates tofalse.
* Condition 2:isOK == true && theString == 'Hello'
* Again,isOKisnull, so this evaluates tofalse.
* Condition 3:isOK != null && theString == 'Hello'
* isOKisnull, soisOK != nullevaluates tofalse.
* Else block: None of the above conditions are true, so the code enters theelseblock and setsx = 4.
:
Apex Boolean Data Type
NEW QUESTION # 37
Which three data types can a SOQL query return?
Choose 3 answers
- A. Double
- B. Long
- C. Integer
- D. List
- E. sObJect
Answer: C,D,E
NEW QUESTION # 38
A developer has a Visualforce page and custom controller to save Account records. The developer wants to display any validation rule violations to the user.
How can the developer make sure that validation rule violations are displayed?
- A. Include <apex:messages> on the Visualforce page.
- B. Use a try/catch with a custom exception class.
- C. Perform the DML using the database.unsert() method,
- D. Add custom controller attributes to display the message.
Answer: A
Explanation:
Validation Rule Violations:
Salesforce automatically throws exceptions for validation rule violations during DML operations.
<apex:messages>is used to display these errors to the user.
Why Not Other Options?
A: Controller attributes alone cannot handle validation messages.
B: A try/catch block does not address validation rule violations effectively.
D:Database.upsert()method is not related to validation error handling.
References:Apex Messages:https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages
/pages_compref_messages.htm
NEW QUESTION # 39
A developer is creating a Lightning web component to show a list of sales records.
The Sales Representative user should be able to see the commission field on each record. The Sales Assistant user should be able to see all fields on the record except the commission field.
How should this be enforced so that the component works for both users without showing any errors?
- A. Use Lightning Data Service to get the collection of sales records.
- B. Use Lightning Locker Service to enforce sharing rules and field-level security.
- C. Use with 8ECTOITYJ2WFORCED in the SOQL that fetches the data for the component.
- D. Use security.stripinaccessible to remove fields inaccessible to the current user.
Answer: D
Explanation:
To ensure that the component works for both users without showing errors due to field-level security, the developer should handle field accessibility programmatically.
Option D: Use Security.stripInaccessible to remove fields inaccessible to the current user.
Correct Answer.
The Security.stripInaccessible method can be used in Apex to remove fields from SObjects that the current user doesn't have access to.
When data is fetched using SOQL, the method can be applied to ensure that inaccessible fields are not included, preventing any security exceptions when the component tries to display them.
This method enforces field-level security and prevents exposure of inaccessible data.
Usage:
// Apex Controller
public with sharing class SalesRecordsController {
@AuraEnabled(cacheable=true)
public static List<Sales_Record__c> getSalesRecords() {
List<Sales_Record__c> records = [SELECT Id, Name, Commission__c, Other_Field__c FROM Sales_Record__c]; return (List<Sales_Record__c>) Security.stripInaccessible(AccessType.READABLE, records);
}
}
WITH SECURITY_ENFORCED enforces field and object level security in SOQL queries.
If a field is not accessible to the user, the query will throw an exception, which may cause errors in the component.
It does not remove inaccessible fields; it enforces security by failing the query.
Option B: Use Lightning Locker Service to enforce sharing rules and field-level security.
Incorrect.
Lightning Locker Service provides security for components but does not enforce sharing rules or field-level security.
Option C: Use Lightning Data Service to get the collection of sales records.
Not Sufficient Alone.
Lightning Data Service respects field-level security but may still cause errors if the component tries to access fields the user cannot see.
Additional handling is needed to prevent errors.
Conclusion:
To ensure the component works for both users and respects field-level security without causing errors, the developer should use Security.stripInaccessible, which is Option D.
Reference:
stripInaccessible Method
Enforcing CRUD and FLS
Incorrect Options:
Option A: Use WITH SECURITY_ENFORCED in the SOQL that fetches the data for the component.
Not Sufficient Alone.
NEW QUESTION # 40
Which annotation exposes an Apex class as a RESTful web service?
- A. @Remote Action
- B. @RestResource
- C. @AuraEnabled
- D. @Httplnvocable
Answer: C
NEW QUESTION # 41
What should a developer use to fix a Lightning web component bug in a sandbox?
- A. Execute Anonymous
- B. VS Code
- C. Force.com IDE
- D. Developer Console
Answer: B
NEW QUESTION # 42
A developer is tasked to perform a security review of the ContactSearch Apex class that exists in the system. Whithin the class, the developer identifies the following method as a security threat: List<Contact> performSearch(String lastName){ return Database.query('Select Id, FirstName, LastName FROM Contact WHERE LastName Like %'+lastName+'%); } What are two ways the developer can update the method to prevent a SOQL injection attack? Choose 2 answers
- A. Use a regular expression on the parameter to remove special characters.
- B. Use variable binding and replace the dynamic query with a static SOQL.
- C. Use the escapeSingleQuote method to sanitize the parameter before its use.
- D. Use the @Readonly annotation and the with sharing keyword on the class.
Answer: B,C
NEW QUESTION # 43
A developer considers the following snippet of code:
Based on this code, what is the value of x?
- A. 0
- B. 1
- C. 2
- D. 3
Answer: C
NEW QUESTION # 44
What is a valid source and destination pair that can send or receive change sets? (Choose 2)
- A. Sandbox to Sandbox
- B. Sandbox to Production
- C. Developer Edition to Sandbox
- D. Developer Edition to Production
Answer: A,B
NEW QUESTION # 45
A Lightning component has a wired property, searchResults, that stores a list of Opportunities. Which definition of the Apex method, to which the searchResults property is wired, should be used?
- A. @AuraEnabled(cacheable=false) public static List<Opportunity> search(String term) { /*implementation*/ }
- B. @AuraEnabled(cacheable=false) public List<Opportunity> search(String term) { /*implementation*/ }
- C. @AuraEnabled(cacheable=true)
public static List<Opportunity> search(String term) { /* implementation*/ } - D. @AuraEnabled(cacheable=true) public List<Opportunity> search(String term) { /*implementation*/ }
Answer: C
NEW QUESTION # 46
Which two are phases in the Salesforce Application Event propagation framework? Choose
2 answers
- A. Default
- B. Bubble
Answer: A,B
NEW QUESTION # 47
Which two are best practices when it comes to Aura component and application event handling?
Choose 2 answers
- A. Try to use application events as opposed to component events.
- B. Use component events to communicate actions that should be handled at the application level.
- C. Reuse the event logic in a component bundle, by putting the logic in the helper.
- D. Handle low-level events in the event handler and re-fire them as higher-level events.
Answer: C,D
NEW QUESTION # 48
Which Lightning code segment should be written to declare dependencies on a Lightning component, c:accountList, that is used in a Visualforce page?
A)
B)
C)
D)
- A. Option D
- B. Option B
- C. Option A
- D. Option C
Answer: C
NEW QUESTION # 49
A developer identifies the following triggers on the Expense__c object:
The triggers process before delete, before insert, and before update events respectively.
Which two techniques should the developer implement to ensure trigger best practices are followed?
Choose 2 answers
- A. Unify the before insert and before update triggers and use Flow for the delete action.
- B. Create helper classes to execute the appropriate logic when a record is saved.
- C. Unify all three triggers in a single trigger on the expense__c object that includes all events.
- D. Maintain all three triggers on the expense__c object, but move the Apex logic out of the trigger definition.
Answer: B,D
NEW QUESTION # 50
A developer needs to implement a custom SOAP Web Service that is used by an external Web Application.
The developer chooses to Include helper methods that are not used by the Web Application In the Implementation of the Web Service Class.
Which code segment shows the correct declaration of the class and methods?
- A.

- B.

- C.

- D.

Answer: C
NEW QUESTION # 51
......
PDI certification dumps - Salesforce PDI PDI guides - 100% valid: https://troytec.dumpstorrent.com/PDI-exam-prep.html