PDI Practice Test Questions

237 Questions


Which two characteristics are true for Lightning Web Component custom events? (Choose 2 answers)


A. Data may be passed In the payload of a custom event using a wire decorated properties.


B. By default a custom event only propagates to its immediate container and to its immediate child component.


C. By default a custom event only propagates to it's immediate container.


D. Data may be passed in the payload of a custom event using a property called detail.





C.
  By default a custom event only propagates to it's immediate container.

D.
  Data may be passed in the payload of a custom event using a property called detail.

Explanation:
C. Event Bubbling (Propagation) Behavior
By default, custom events in LWC do not bubble up the DOM (unlike standard DOM events).
A custom event only propagates to the component that dispatched it (the host) and its immediate parent (container).
If you want an event to bubble up the component hierarchy, you must set bubbles: true when creating the event.
D. Passing Data in the Payload (detail Property)
Custom events in LWC use a detail property to pass data in the payload.
Example:
javascript
const event = new CustomEvent('notify', {
detail: { message: 'Hello World' } // Data is passed here
});
this.dispatchEvent(event);
The parent component can access the data via event.detail.

Universal Containers has developed custom Apex code and Lightning Components in a Sandbox environment. They need to deploy the code and associated configurations to the Production environment. What is the recommended process for deploying the code and configurations to Production?


A. Use a change set to deploy the Apex code and Lightning Components.


B. Use the Force.com IDE to deploy the Apex code and Lightning Components.


C. Use the Ant Migration Tool to deploy the Apex code and Lightning Components.


D. Use Salesforce CLI to deploy the Apex code and Lightning Components.





A.
  Use a change set to deploy the Apex code and Lightning Components.

✅ Explanation:
Change Sets are the recommended deployment method when moving customizations (like Apex code, Lightning Components, configurations, etc.) between related Salesforce orgs, such as from Sandbox to Production.

Why A. Change Set is correct:
Designed specifically for deploying between environments that are in the same Salesforce org family (e.g., a Developer Sandbox to Production).

UI-based and user-friendly—ideal for admins and developers.
Supports most metadata types including Apex classes, Lightning Components, Custom Objects, Workflows, etc.
Ensures proper dependency resolution and validation before deploying.

Which annotation should a developer use on an Apex method to make it available to be wired to a property in a Lightning web component?


A. @RemoteAction


B. @AureEnabled


C. @AureEnabled (cacheable=true)


D. @RemoteAction(|cacheable=true)





C.
  @AureEnabled (cacheable=true)

Explanation?

@AuraEnabled is the required annotation to expose an Apex method to Lightning Web Components (LWC) or Aura Components.
(cacheable=true) is needed when the method is used with @wire in an LWC, because:
Wire methods require cacheable=true to avoid errors.
It enables client-side caching, improving performance by preventing unnecessary server calls.
Example Usage:

Apex Class:
java
public with sharing class MyApexController {
@AuraEnabled(cacheable=true)
public static List getAccounts() {
return [SELECT Id, Name FROM Account LIMIT 10];
}
}

LWC JavaScript (Wire Example):
javascript
import { LightningElement, wire } from 'lwc';
import getAccounts from '@salesforce/apex/MyApexController.getAccounts';
export default class MyComponent extends LightningElement {
@wire(getAccounts)
accounts;
}

A custom picklist field, Food_Preference c, exist on a custom object. The picklist contains the following options: 'Vegan','Kosher','No Preference'. The developer must ensure a value is populated every time a record is created or updated. What is the most efficient way to ensure a value is selected every time a record is saved?


A. Set "Use the first value in the list as the default value" as True.


B. Set a validation rule to enforce a value is selected.


C. Mark the field as Required on the field definition.


D. Mark the field as Required on the object's page layout.





C.
  Mark the field as Required on the field definition.

✅ Explanation:
Marking the field as Required at the field definition level (i.e., in the object schema) is the most efficient and reliable way to ensure that every time a record is created or updated, a value must be provided for the Food_Preference__c picklist field.

Benefits:

Enforced universally—regardless of whether the record is created via UI, API, Apex, Flow, or any integration.
No need for additional logic or validation rules.
Ensures data integrity at the database level.

Universal Container is building a recruiting app with an Applicant object that stores information about an individual person that represents a job. Each application may apply for more than one job. What should a developer implement to represent that an applicant has applied for a job?


A. Master-detail field from Applicant to Job


B. Formula field on Applicant that references Job


C. Junction object between Applicant and Job


D. Lookup field from Applicant to Job





C.
  Junction object between Applicant and Job

✅ Explanation:

In this scenario:
One Applicant can apply to multiple Jobs.
One Job can have multiple Applicants.
This is a many-to-many relationship, and the best way to model that in Salesforce is with a junction object.
A Junction Object:

Is a custom object that has two master-detail relationships:

One to the Applicant object
One to the Job object
Each record in the junction object represents a single application of one Applicant to one Job.
This allows tracking additional data per application (e.g., application date, status, interview notes).

Universal Hiring uses Salesforce to capture job applications. A salesforce administrator created two custom objects; Job c acting as the maste object, Job _Application c acting as the detail. Within the Job c object, a custom multi-select picklist, preferred Locations c, contains a list of approved states for the position. Each Job_Application c record relates to a Contact within the system through a master-detail relationship. Recruiters have requested the ability to view whether the Contact's Mailing State value matches a value selected on the Preferred_Locations c field, within the Job_Application c record. Recruiters would like this value to be kept in sync if changes occur to the Contact's Mailing State. What is the recommended tool a developer should use to meet the business requirement?


A. Roll-up summary field


B. Apex trigger


C. Formula field


D. Record-triggered flow





D.
  Record-triggered flow

Explanation:
Business Requirement:
Compare the Contact's MailingState with the Job's Preferred_Locations__c (multi-select picklist).
Automatically sync this comparison result whenever the Contact's address or Job's preferred locations change.
Why Record-Triggered Flow?
Real-time updates: Fires when a Contact or Job record is created/updated.
Can query related records: Access the Job_Application__c, Job__c, and Contact fields.
Flexible logic: Can check if MailingState is in Preferred_Locations__c (using INCLUDES for multi-select).
Low-code: Easier to maintain than Apex triggers.

Which three steps allow a custom SVG to be included in a Lightning web component? Choose 3 answers


A. Upload the SVG as a static resource.


B. Import the static resource and provide a getter for it in JavaScript.


C. Reference the getter in the HTML template.


D. Reference the import in the HTML template.


E. Import the SVG as a content asset file.





A.
  Upload the SVG as a static resource.

B.
  Import the static resource and provide a getter for it in JavaScript.

C.
  Reference the getter in the HTML template.

Step-by-Step Explanation:

A. Upload the SVG as a static resource
Go to Setup → Static Resources and upload the SVG file.
This makes the SVG accessible in Lightning Web Components (LWC).
B. Import the static resource and provide a getter in JavaScript
In your LWC’s JavaScript file, import the static resource and create a getter to expose it:
javascript
import { LightningElement } from 'lwc';
import mySvg from '@salesforce/resourceUrl/mySvgResource'; // Static resource name
export default class MyComponent extends LightningElement {
get svgUrl() {
return mySvg; // Returns the path to the SVG
}
}
C. Reference the getter in the HTML template
Use the getter in the HTML to display the SVG (e.g., in an tag):
html

What is the result of the following code snippet?


A. Accounts are inserted.


B. Account Is inserted.


C. 200 Accounts are inserted.


D. 201 Accounts are Inserted.





D.
  201 Accounts are Inserted.

💡 Explanation:
The for loop runs from i = 0 to i = 200, inclusive, which means 201 iterations total.
On each iteration, the line insert acct; is executed.
Therefore, the same Account record is being inserted 201 times, which will cause a runtime error unless the Account object is cloned or has a unique Name or required fields.

What should a developer use to fix a Lightning web component bug in a sandbox?


A. Developer Console


B. VS Code


C. Force.com IDE





B.
  VS Code

Explanation:
VS Code (with Salesforce Extensions) is the modern, recommended tool for Lightning Web Component (LWC) development because:

It provides real-time error checking, code completion, and debugging tools specific to LWC.
It integrates seamlessly with Salesforce CLI for deploying and retrieving metadata.
It supports source tracking and version control (Git).

✅ VS Code (B) is the best choice for fixing LWC bugs efficiently.
🚫 Avoid Force.com IDE (C) (outdated) and Developer Console (A) (too limited).
Bonus: Steps to Debug LWC in VS Code
Install VS Code + Salesforce Extension Pack.
Use SFDX: Retrieve Source to pull the component from the sandbox.
Debug using Chrome DevTools (for runtime issues) or LWC linter (for syntax errors).
Deploy fixes with SFDX: Deploy to Sandbox.

✅ ✅ B (VS Code) is the correct and modern approach.

A developer migrated functionality from JavaScript Remoting to a Lightning web component and wants to use the existing getOpportunities() method to provide data. What to do now?


A. The method must be decorated with (cacheable=true).


B. The method must be decorated with @AuraEnabled.


C. The method must return a JSON Object.


D. The method must return a String of a serialized JSON Array.





B.
  The method must be decorated with @AuraEnabled.

✅ Explanation:

To make an Apex method accessible to a Lightning Web Component (LWC), it must be decorated with the @AuraEnabled annotation.
When migrating from JavaScript Remoting (used with Visualforce) to LWC:
You should:
Add @AuraEnabled to your Apex method.
Ensure the method is public static.
Return data types supported by LWC (e.g., List, Map, primitives).
public with sharing class OpportunityController {
@AuraEnabled
public static List getOpportunities() {
return [SELECT Id, Name, Amount FROM Opportunity LIMIT 10];
}
}
import getOpportunities from '@salesforce/apex/OpportunityController.getOpportunities';

What are two considerations for running a flow in debug mode? Choose 2 answers


A. Callouts to external systems are not executed when debugging a flow.


B. Clicking Pause or executing a Pause element closes the flow and ends debugging.


C. Input variables of type record cannot be passed into the flow,


D. DML operations will be rolled back when the debugging ends.





A.
  Callouts to external systems are not executed when debugging a flow.

D.
  DML operations will be rolled back when the debugging ends.

Explanation:

- Callouts to external systems are not executed when debugging a flow because the debug mode runs in a controlled environment where external interactions are prevented.
- DML operations (such as inserts, updates, and deletes) are rolled back when debugging ends, ensuring that test runs do not affect actual data.

A developer Is asked to create a Visualforce page that lists the contacts owned by the current user. This component will be embedded In a Lightning page. Without writing unnecessary code, which controller should be used for this purpose?


A. Standard list controller


B. Standard controller


C. Lightning controller


D. Custom controller





A.
  Standard list controller

Explanation:

Standard list controllers are used when you need to display a list of records (like Contacts). Since the requirement is to list contacts owned by the current user, and there's no mention of custom logic, a standard list controller for the Contact object is the most efficient and appropriate choice.

It provides built-in pagination, filtering, and sorting without the need for custom Apex code. This is ideal for use cases where basic list display is enough, especially when embedding into a Lightning page.

Other options:

B. Standard controller: Used for a single record, not a list.
C. Lightning controller: This is not a standard Visualforce option—confusing terminology.
D. Custom controller: Unnecessary unless you need custom logic, which this question does not require.


Page 1 out of 20 Pages