PDI Practice Test Questions

237 Questions


A developer must provide custom user interfaces when users edit a Contact in either Salesforce Classic or Lightning Experience. What should the developer use to override the Contact's Edit button and provide this functionality?


A. A Visualforce page in Salesforce Classic and a Lightning component in Lightning Experience


B. A Lightning component in 5alesforce Classic and a Lightning component in lightning Experience


C. A Visualforce page in Salesforce Classic and a Lightning page in Lightning Experience


D. A Lightning page in Salesforce Classic and a Visualforce page in Lightning Experience





A.
  A Visualforce page in Salesforce Classic and a Lightning component in Lightning Experience

Explanation:

Salesforce allows developers to override standard buttons like Edit with custom user interfaces, but the technology used depends on the UI experience:

βœ”οΈ For Salesforce Classic:

You can only override buttons using Visualforce pages.
Lightning components do not run in Classic.

βœ”οΈ For Lightning Experience:

You can override buttons with Lightning components (Aura or LWC).
This allows for modern, responsive UI.

πŸ”§ Override Configuration:

When overriding the Edit button on the Contact object, Salesforce lets you specify:

A Visualforce Page for Classic
A Lightning Component for Lightning Experience

❌ Why other options are incorrect:

B. Lightning component in both Classic and Lightning
❌ Lightning components cannot run in Classic.

C. Visualforce page and Lightning page
❌ Lightning pages (App Builder pages) are not valid for button overrides.

D. Lightning page in Classic and Visualforce in Lightning
❌ Lightning pages don’t work in Classic, and Visualforce in Lightning defeats the purpose of a native Lightning experience.

A developer is creating a test coverage for a class and needs to insert records to validate functionality. Which method annotation should be used to create records for every method in the test class?


A. @BeforeTest


B. @isTest(SeeAllData=True)


C. @TestSetup


D. @PreTest





C.
  @TestSetup

Explanation:

The @TestSetup annotation is used in Apex test classes to define a method that creates test data that is shared across all test methods in the class.

Benefits:

Runs once before any @isTest methods in the class
Helps keep tests efficient and consistent
Prevents the need to duplicate record creation in each test method

πŸ” Example:

@isTest
private class MyTestClass {

@testSetup
static void setupData() {
Account acc = new Account(Name='Test Account');
insert acc;
}

@isTest
static void testLogic() {
// Access shared data created in @TestSetup
Account acc = [SELECT Id FROM Account LIMIT 1];
// Assertions and logic testing
}
}

❌ Why other options are incorrect:

A. @BeforeTest
❌ Not a valid Apex annotation (confused with other languages like JUnit).

B. @isTest(SeeAllData=True)
❌ Allows access to real org data (not recommended)
Does not create test data or share it across test methods.

D. @PreTest
❌ Not a valid annotation in Apex.

What should a developer use to obtain the Id and Name of all the Leads. Accounts, and Contacts that hove the company name "Universal Containers"?


A. FIND 'Universal Containers' IN Name Fields RETURNING leadjid, name), accounted, name), contacted, name)


B. FIND Universal Containers' IN CompanyName Fietds RETURNING lead{ld. name), accounted, name), contacted, name)


C. SELECT lead(id, name). accountOd, name), contacted, name) FROM Lead, Account, Contact WHERE Name = "universal Containers'


D. SELECT Lead.id. Lead.Name, Account.Id, AccountName, Contacted, Contact.Name FROM Lead, Account, Contact WHERE CompanvName * Universal Containers'





A.
  FIND 'Universal Containers' IN Name Fields RETURNING leadjid, name), accounted, name), contacted, name)

Explanation:

To search across multiple objects (Lead, Account, Contact) where the name or company contains "Universal Containers", you should use SOSL (Salesforce Object Search Language), not SOQL.

βœ… Why SOSL is appropriate:

SOSL allows searching across multiple objects in one query
It's ideal when you want to search text fields like Name or Company
Returns a list of lists, one per object

πŸ” Breakdown of the correct syntax:

FIND 'Universal Containers'
IN Name Fields
RETURNING
Lead(Id, Name),
Account(Id, Name),
Contact(Id, Name)

FIND 'Universal Containers' β€” searches for this term
IN Name Fields β€” limits search to Name fields
RETURNING β€” specifies which objects and fields to return

❌ Why the other options are incorrect:

B. IN CompanyName Fields
❌ CompanyName is not a searchable field group in SOSL β€” use Name Fields.

C. SELECT FROM multiple objects in one SOQL
❌ SOQL does not support querying multiple unrelated objects in a single SELECT.

D. Invalid SOQL syntax with multiple objects and misused WHERE clause
❌ Mixing unrelated objects and incorrect field references.

A developer at AW Computing is tasked to create the supporting test class for a programmatic customization that leverages records stored within the custom object, Pricing Structure c. AW Computing has a complex pricing structure for each item on the store, spanning more than 500 records. hich two approaches can the developer use to ensure Pricing _Structure c records are available when the test class is executed? Choose 2 answers


A. Use a Test Date Factory class.


B. Use the @raTeat (seeAllData=true) annotation.


C. Use the Test. leadtear{} method,


D. Use without shering on the class declaration.





A.
  Use a Test Date Factory class.

B.
  Use the @raTeat (seeAllData=true) annotation.

Explanation:

When writing test classes in Apex, the goal is to ensure that all required test data is created or made available during the test execution. Let’s look at the two valid options:

βœ”οΈ A. Use a Test Data Factory class

βœ… Recommended best practice

A Test Data Factory is a reusable class designed to create test data (e.g., 500 Pricing_Structure__c records).
It improves test reliability, readability, and maintainability.
Keeps test methods clean by separating data setup from test logic.

βœ”οΈ B. Use the @isTest(seeAllData=true) annotation

βœ… Allows access to actual org data during test execution.
Can be used if 500+ Pricing_Structure__c records already exist and are too complex to replicate.
⚠️ Not recommended for managed packages or long-term maintainability, as it's not future-proof (data may change or be deleted).

❌ Incorrect Options:

C. Use the Test.loadData() method
❌ This option is not listed, but if you meant Test.loadData(), that could work only if a static .csv file is available.
However, Test.leadtear{} is not a valid Apex method β€” possibly a typo.

D. Use without sharing on the class declaration
❌ This affects record visibility, not data availability.
It allows access to records the running user doesn't own or have access to, but doesn't create or load data for tests.

Universal Container wants Opportunities to no longer be editable when reaching the Clousd stage. How should a develoiper accomplish this?


A. Use the Process Automation setting.


B. Mark fields as read-only on the page layout.


C. Use flow Builder


D. Use a validation rule.





D.
  Use a validation rule.

Explanation:

To prevent editing Opportunities once they reach the "Closed" stage, the best solution is:

βœ… Create a validation rule that prevents updates when StageName = 'Closed'
Validation rules allow you to enforce business logic and prevent specific changes based on field values or other conditions.

πŸ” Example Validation Rule:

AND(
ISCHANGED(StageName),
ISPICKVAL(StageName, "Closed")
)

Or to prevent any edits once the Opportunity is closed:

You can also add exceptions if needed (e.g., allow system admins).

❌ Why other options are incorrect:

A. Use the Process Automation setting
❌ Not a valid Salesforce setting for field/edit restrictions.

B. Mark fields as read-only on the page layout
❌ Only affects the UI and can be bypassed via API or integration tools.

C. Use Flow Builder
❌ Flows are good for automation but not ideal for enforcing edit restrictions. You’d still need a validation rule or Apex.

Which two events need to happen when deploying to a production org? Choose 2 answers


A. All triggers must have at least 1% test coverage.


B. All Apex code must have at least 75% test coverage.


C. All triggers must have at least 75% test coverage.


D. All test and triggers must have at least 75% test coverage combined





B.
  All Apex code must have at least 75% test coverage.

C.
  All triggers must have at least 75% test coverage.

Explanation:

Salesforce Deployment Requirements:

75% Test Coverage: Applies to all Apex code (including triggers, classes, and controllers) when deploying to production.
Triggers Are Apex Code: Triggers are not exempt; they must individually meet the 75% coverage threshold.

Why Not the Others?

A. 1% Trigger Coverage: False (Salesforce requires 75%).
D. Combined 75% Coverage: False (Each trigger and class must meet 75% individually).

A Salesforce Administrator is creating a record-triggered flow. When certain criteria are met, the flow must call an Apex method to execute complex validation involving several types of objects. When creating the Apex method, which annotation should a developer use to ensure the method Can be used within the flow?


A. @future


B. @RemoteAction


C. @InvocableMethod


D. @AuraEnaled





C.
  @InvocableMethod

Explanation:

To make an Apex method available for use in a Flow, it must be annotated with:

@InvocableMethod

This annotation exposes an Apex method to Flow Builder, allowing it to be called from record-triggered, screen, or autolaunched flows.

πŸ” Example:

public class FlowValidationHelper {
@InvocableMethod
public static List validateData(List input) {
// Your complex validation logic here
}
}

❌ Why the other options are incorrect:

A. @future
❌ Used for asynchronous processing, not for exposing methods to flows.

B. @RemoteAction
❌ Used to expose methods to Visualforce and JavaScript, not flows.

D. @AuraEnabled
❌ Used to expose methods to Lightning components (Aura/LWC), not flows.

What are three ways for a developer to execute tests in an org? Choose 3.


A. Bulk API


B. Tooling API


C. Setup Menu


D. Salesforce DX


E. Metadata API.





B.
  Tooling API

C.
  Setup Menu

D.
  Salesforce DX

Explanation:

Salesforce provides several ways for developers to execute tests in an org. Here's a breakdown:

βœ”οΈ B. Tooling API

βœ… True

The Tooling API supports running tests programmatically, often used by IDEs and CI tools.
You can execute specific test classes or methods and retrieve code coverage results.

βœ”οΈ C. Setup Menu

βœ… True

Developers and admins can run Apex tests directly from Setup by navigating to:
Setup β†’ Apex Test Execution

βœ”οΈ D. Salesforce DX (SFDX CLI)

βœ… True

Salesforce DX provides the sfdx force:apex:test:run command to run tests from the command line.
Widely used in automated CI/CD pipelines.

❌ Incorrect Options:

A. Bulk API
❌ Not used for running Apex tests
Designed for importing, exporting, and deleting large volumes of data.

E. Metadata API
❌ Used for deploying and retrieving metadata
Cannot run tests directly, though tests are run as part of deployments.

For which three items can a trace flag be configured? Choose 3 answers


A. Process Builder


B. Visualforce


C. Apex Class


D. Apex Trigger


E. User





C.
  Apex Class

D.
  Apex Trigger

E.
  User

Explanation:

A trace flag in Salesforce is used to enable debug logging for specific items. Here’s how the correct answers apply:

βœ”οΈ C. Apex Class

βœ… True
You can set a trace flag for a specific Apex Class to debug its behavior and execution.

βœ”οΈ D. Apex Trigger

βœ… True
You can enable a trace flag on a specific Apex Trigger to log its execution.

βœ”οΈ E. User

βœ… True
This is the most common use β€” enabling a trace flag for a user captures all code run in their context (e.g., when testing something in the UI or running a flow).

❌ Incorrect Options:

A. Process Builder
❌ False
You cannot configure trace flags directly for Process Builder. However, if it triggers Apex code, that can be traced.

B. Visualforce
❌ False
You cannot directly set a trace flag for a Visualforce page. You would trace the user or Apex class involved.

Universal Containers implemented a private sharing model for the Account object. A custom Account search tool was developed with Apex to help sales representatives find accounts that match multiple criteria they specify. Since its release, users of the tool report they can see Accounts they do not own. What should the developer use to enforce sharing permission for the currently logged-in user while using the custom search tool?


A. Use the schema describe calls to determine if the logged-in users has access to the Account object.


B. Use the without sharing keyword on the class declaration.


C. Use the UserInfo Apex class to filter all SOQL queries to returned records owned by the logged-in user.


D. Use the with sharing keyword on the class declaration.





D.
  Use the with sharing keyword on the class declaration.

Explanation:

In Salesforce, when you build custom Apex code (like a search tool), the Apex class by default does not enforce sharing rules unless explicitly stated. To ensure that users only see records they are allowed to see based on the org's sharing model (e.g., private sharing for Account), you need to declare the class with:

with sharing

This ensures the code respects record-level sharing rules for the currently logged-in user.

πŸ›‘ Why the other options are incorrect:

A. Use the schema describe calls to determine access to the Account object
❌ This checks object-level permissions, not record-level sharing.

B. Use the without sharing keyword
❌ This explicitly ignores sharing rules, which is the opposite of what's needed here.

C. Use the UserInfo class to filter queries
❌ Manually filtering by owner is not sufficient β€” users may have access to records via sharing rules, roles, or teams, not just ownership.

A developer creates a custom exception as shown below: public class ParityException extends Exception {} What are two ways the developer can fire the exception in Apex? Choose 2 answers


A. new ParityException();:


B. throw new ParityException("parity does not match");


C. new ParityException('parity does not match');


D. throw new ParityException();





B.
  throw new ParityException("parity does not match");

D.
  throw new ParityException();

Explanation:

Given this custom exception declaration:

public class ParityException extends Exception {}

There are two valid ways to throw (fire) this exception in Apex:

βœ”οΈ B. throw new ParityException("parity does not match");

βœ… Correct
You can pass a custom message to the exception constructor.
This message will be available via get Message().

βœ”οΈ D. throw new ParityException();

βœ… Correct
You can throw the exception without passing any arguments.
This uses the default constructor.

❌ Incorrect Options:

A. new ParityException();
❌ Just instantiates the exception but does not throw it.

C. new ParityException('parity does not match');
❌ Similar to A β€” it creates the exception but does not throw it.

What are two use cases for executing Anonymous Apex code? Choose 2 answers


A. To delete 15,000 inactive Accounts In a single transaction after a deployment


B. To schedule an Apex class to run periodically


C. To run a batch Apex class to update all Contacts


D. To add unit test code coverage to an org





B.
  To schedule an Apex class to run periodically

C.
  To run a batch Apex class to update all Contacts

Explanation:

Here are the two correct use cases for executing Anonymous Apex:

Scheduling an Apex Class (B):

Anonymous Apex can schedule jobs using System.schedule().

Example:

System.schedule('Daily Update', '0 0 12 * * ?', new MyScheduledClass());

Running Batch Apex (C):

Anonymous Apex can launch batch jobs with Database.executeBatch().

Example:

Database.executeBatch(new UpdateContactsBatch(), 200);

Why Not the Others?

A. Deleting 15,000 Accounts in a single transaction:
Governor limit violation: Anonymous Apex has a 10,000-record DML limit. Use Batch Apex instead.

D. Adding unit test coverage:
Tests must be in test classes (@isTest). Anonymous Apex doesn’t count toward coverage.


Page 6 out of 20 Pages
Previous