Salesforce Plat-Dev-301 Practice Exam Questions & Answers
Salesforce Plat-Dev-301 Exam Details
Key details for this exam, checked against the published exam outline
- Exam Code
- Plat-Dev-301
- Full Name
- Salesforce Certified Platform Developer II
- Issuing Body
- Salesforce
- Question Format (Our Bank)
- Multiple Choice
- Delivery
- Online proctored or at a testing center
- Eligibility
- Must hold Salesforce Certified Platform Developer I certification
- Validity
- Does not expire as long as yearly maintenance requirements are completed
- Full Question Set
- 161 questions Get All Questions
Free Plat-Dev-301 Practice Questions
Answer each question, then see the correct answer and why it is right
Question 1 Domain 3 User Interface
A developer has been asked to build a Lightning web component that lets users open a new Case for a chosen product, straight from a custom Lightning page. The component's input fields are arranged in an irregular pattern over a picture of the product so that users can more easily grasp what each field represents. Which two components should the developer use to create the Case from within the Lightning web component?161718
3233
When a requirement calls for a 'non-linear' or highl34y customized layout, the high-35level lightning-record-form (A) is not a good fit, since it automatically draws fields in a standard grid or according to a page layout. Building a bespoke interface, such as placing fields over a product image, requires finer control over placement.
The lightning-record-edit-form (B) is the best container for this case. It handles the data work (loading and saving records) without enforcing a rigid visual structure. Inside this form, the developer places a lightning-input-field (C) for each Case field. Each of these components is context-aware, so it picks up metadata such as field labels, picklist values, and validation rules straight from the Salesforce object definition.
Because lightning-input-field components can sit anywhere within the lightning-record-edit-form tag, the developer can apply custom CSS (absolute positioning or CSS Grid) to position them exactly over the product image as required. Standard lightning-input (D) components would also work, but they would need considerably more manual code to manage data binding, type conversion, and validation. Pairing B with C is therefore the most efficient and platform-aligned choice.
Question 2 Domain 2 Process Automation, Logic, and Integration
A developer is building code that must send callouts to an external web service. In which situation must the callout be executed inside an asynchronous method?
Salesforce does not allow a callout to be sent directly from an Apex trigger (Option C). This is a core architectural limit of the platform. Triggers run inside a database transaction. If a trigger could make a synchronous callout, that transaction, along with every row lock it holds, would stay open while the system waited for the external response. The result could be serious performance problems and transaction timeouts.
To make a callout in response to a trigger event, the developer must move the callout logic into an asynchronous context, such as a @future(callout=true) method, a Queueable class, or by publishing a Platform Event.
Option A is incorrect because although asynchronous methods allow higher CPU time, they do not raise the maximum timeout for an individual callout (120 seconds). Option B is incorrect because REST is simply a protocol and does not determine whether a call is synchronous. Option D is incorrect because the limit for callouts in one transaction is 100, so 10 callouts would still be allowed in a synchronous context (provided they are not in a trigger). Therefore, the presence of a trigger is the only listed factor that programmatically requires an asynchronous approach.
Question 3 Domain 2 Process Automation, Logic, and Integration
A developer keeps configuration values in custom settings, and those values are updated from time to time. After a number of recently refreshed sandboxes were set up, tests began failing in some of them. What should be done to prevent this issue from occurring in the future?
5
The prob6lem described here stems directly from the way Salesforce handles data during sandbox refreshes and unit testing. Custom Settings (both List and Hierarchy) keep their information as data records. By default, sandbox refreshes do not copy data records from Production unless the sandbox is a Full Sandbox. In addition, Apex unit tests are cut off from organization data; they cannot 'see' Custom Setting records unless those records are explicitly created within the test or the @isTest(SeeAllData=true) annotation is used, which is considered poor practice.
Custom Metadata (Option C) addresses this by treating configuration records as metadata rather than data. Because they are metadata, the records are automatically carried over in every sandbox refresh and can be deployed through Change Sets or the Salesforce CLI. Most significantly, Custom Metadata is accessible to Apex unit tests without requiring setup data to be created or test isolation to be bypassed. This keeps configuration-dependent logic consistent across all environments and ensures tests pass reliably after a refresh. Moving from Custom Settings to Custom Metadata is the current Salesforce standard for environment-independent configuration management.
Get the complete Plat-Dev-301 question set
Get Full AccessQuestion 4 Domain 1 Advanced Developer Fundamentals
An organization needs support managers to have visibility into every case regardless of ownership. Support agents, however, should only be able to view cases they own or cases owned by a user in their own role or a role beneath it. Which sharing mechanism should a developer implement to meet this requirement?
This requirement reflects a standard top-down access pattern, which is best addressed by the Role Hierarchy (Option C).
When the Organization-Wide Default (OWD) for an object such as Case is set to Private, the Role Hierarchy automatically provides the following behavior:
Managers can view subordinates' data: Users positioned higher in the hierarchy automatically receive access to records owned by, or shared with, users beneath them. Placing support managers at the top of the hierarchy allows them to view every case owned by the agents.
Agents can view only limited data: Agents can access only the records they own or that have been shared with them. The requirement that they see cases owned by 'someone in their role or a subordinate role' is precisely how the hierarchy enables vertical data flow.
Although Criteria-based sharing rules (Option D) could potentially share cases with managers, maintaining the 'subordinate' logic dynamically becomes far more difficult as the team grows. Sharing Sets (Option A) apply specifically to Experience Cloud (External) users and are not relevant to internal support staff. Apex Managed Sharing (Option B) is a 'last resort' for complex, programmatic sharing logic that cannot be implemented declaratively. Because the requirement aligns directly with the standard manager-subordinate relationship, the Role Hierarchy is the most efficient and standard solution.
Question 5 Domain 1 Advanced Developer Fundamentals
A test method invokes an @future method that increments a field, but the assertion fails because the field still reads 0. Which approach is the best way to resolve this?
Java
@isTest
static void testIncrement() {
Account acct = new Account(Name = 'Test', Number_Of_Times_Viewed__c = 0);
insert acct;
AuditUtil.incrementViewed(acct.Id); // This is the @future method
Account acctAfter = [SELECT Number_Of_Times_Viewed__c FROM Account WHERE Id = :acct.Id][0];
System.assertEquals(1, acctAfter.Number_Of_Times_Viewed__c);
}
Asynchronous methods, like those marked with @future, are not executed right away when invoked in Apex. Rather, they are placed in a queue and processed once system resources become free. In a unit test, if a future method is called and the database is queried immediately afterward, the future method has probably not run yet, which explains the '0' seen in the assertion.
To test asynchronous code, the call must be enclosed by Test.startTest() and Test.stopTest() (Option D). Upon reaching Test.stopTest(), the test script pauses and the platform forces all queued asynchronous jobs (future methods, batch jobs, queueable jobs) to complete synchronously.
By placing the AuditUtil.incrementViewed(acct.Id) call inside this block, the increment logic is guaranteed to finish before the next line (the SOQL query) executes, so the database shows the updated value. Option B is wrong because inserting the account is a synchronous operation and does not need the stopTest wait. Options A and C sidestep the problem instead of properly testing the logic. Option D is the standard platform-required pattern for testing asynchronous side effects.
Question 6 Domain 4 Testing, Debugging, and Deployment
A developer is creating a Lightning web component that fetches data from Salesforce and stores it in the record property:
JavaScript
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
export default class Record extends LightningElement {
@api fields;
@api recordId;
record;
}
Which change must the developer make to the component so that it obtains the data from Salesforce?
To load record data in a Lightning Web Component through the Lightning Data Service (LDS), the developer needs to apply the @wire decorator together with the getRecord wire adapter.
Option D shows the correct syntax. The @wire decorator needs the adapter name (getRecord) and a configuration object. That configuration has to contain the recordId and either the fields or layoutTypes to fetch. Adding the $ prefix (for instance, '$recordId') makes the property 'reactive.' As a result, whenever the value of recordId or fields changes, the wire service automatically provisions the data from Salesforce again.
Options A and C are wrong because @api is meant to expose public properties and does not wire data. Option B is wrong because getRecord needs a field list or layout type to determine which data points to retrieve from the server. Using the reactive $fields keeps the component flexible so it can load different field sets as specified by its parent component.
Question 7 Domain 2 Process Automation, Logic, and Integration
An organization must execute distinct logic depending on the record type of an Opportunity. Which code segment fulfills this requirement while adhering to best practices?
A.
Java
List
Map
for (RecordType rt : recTypes) {
recTypeMap.put(rt.Name, rt.Id);
}
for (Opportunity o : Trigger.new) {
if(o.RecordTypeId == recTypeMap.get('New')) {
// do some logic Record Type 1
} else if (o.RecordTypeId == recTypeMap.get('Renewal')) {
// do some logic for Record Type 2
}
}
B.
Java
for (Opportunity o : Trigger.new) {
if (o.RecordType.Name == 'New') {
// do some logic Record Type 1
}
else if (o.RecordType.Name == 'Renewal') {
// do some logic for Record Type 2
}
}
C.
Java
List
Map
for (RecordType rt : recTypes) {
recTypeMap.put(rt.Name, rt.Id);
}
for (Opportunity o : Trigger.new) {
if (recTypeMap.get('New') != null && o.RecordTypeId == recTypeMap.get('New')) {
// do some logic Record Type 1
}
else if (recTypeMap.get('Renewal') != null && o.RecordTypeId == recTypeMap.get('Renewal')) {
// do some logic for Record Type 2
}
}
D.
Java
Id newRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('New').getRecordTypeId();
Id renewalRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Renewal').getRecordTypeId();
for (Opportunity o : Trigger.new) {
if (o.RecordTypeId == newRecordTypeId) {
// do some logic Record Type 1
}
else if (o.RecordTypeId == renewalRecordTypeId) {
// do some logic for Record Type 2
}
}
Within Salesforce Apex, the recommended approach for obtaining Record Type IDs is to skip SOQL and rely on Schema Describe methods instead. Option D calls Schema.SObjectType.Opportunity.getRecordTypeInfosByName(), which pulls metadata straight from the local cache of the application.
Option D is preferable to the alternatives for three main reasons:
Governor Limits: Salesforce caps synchronous transactions at 100 SOQL queries. Options A and C each spend one of those queries merely to read metadata. When numerous triggers and flows run together, conserving SOQL for genuine business data becomes essential. Describe calls are not counted toward the SOQL cap.
Performance: Reading from the metadata cache is considerably quicker than running a database query, which results in reduced CPU consumption and quicker trigger processing.
Data Integrity: Option B is a frequent anti-pattern that leads to a runtime failure. Within an Apex Trigger, Trigger.new records hold only the object's own fields and omit related fields (cross-object fields) such as RecordType.Name. Reading o.RecordType.Name directly would either return null or throw 'System.SObjectException: SObject row was retrieved via SOQL without querying the requested field.'
Relying on the Schema class lets the developer produce code that is bulk-safe and performant, and avoids hardcoding IDs, since those can differ between Sandboxes and Production environments.
Question 8 Domain 4 Testing, Debugging, and Deployment
Universal Containers has a custom Lightning page that offers a step-by-step wizard for locating Accounts. One wizard step lets the user type text into a text field, ERP_Number__c, which is then applied in a query to retrieve matching Accounts.
Java
erpNumber = erpNumber + '%';
List
A developer encounters the exception 'SOQL query not selective enough'. What should be done to fix this problem?
The 'SOQL query not selective enough' error arises when a query against an object holding a large number of records (typically over 200,000) does not use a filtered index to narrow the result set effectively. In Salesforce, the query optimizer must be able to use an index to scan a small enough percentage of the total records to keep performance acceptable. When a query filters on a non-indexed field, the system is forced to perform a full table scan, which triggers this exception to prevent performance degradation.
To resolve this, the developer must make sure the field used in the WHERE clause is indexed. Marking a custom field as an 'External ID' or 'Unique' automatically creates a custom index on that field. By marking ERP_Number__c as an External ID, the platform generates an underlying database index, allowing the query optimizer to quickly locate matching records without scanning the entire table. While the LIKE operator with a trailing wildcard (for example, 'Text%') can utilize an index, the query is only considered 'selective' if the filter narrows the results below the platform's selectivity thresholds (typically 10% of the first million records). Making the field an External ID is the standard programmatic solution to provide the necessary indexing for selectivity. Option A is incorrect because moving a non-selective query to an asynchronous process does not change the fact that it is non-selective; it will still fail.
Question 9 Domain 4 Testing, Debugging, and Deployment
Which code sample offers the most efficient Apex trigger logic for populating a Lead's Region according to its PostalCode, by way of the custom Region__c object?
A.
Java
Set
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
zips.add(l.PostalCode);
}
}
List
Map
for(Region__c r : regions) {
zipMap.put(r.Zip_Code__c, r.Region_Name__c);
}
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
l.Region__c = zipMap.get(l.PostalCode);
}
}
B.
Java
Set
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
zips.add(l.PostalCode);
}
}
for (Lead l : Trigger.new) {
List
for (Region__c r : regions) {
if(l.PostalCode == r.Zip_Code__c) {
l.Region__c = r.Region_Name__c;
}
}
}
C.
Java
for (Lead l : Trigger.new) {
Region__c reg = [SELECT Region_Name__c FROM Region__c WHERE Zip_Code__c = :l.PostalCode];
l.Region__c = reg.Region_Name__c;
}
D.
Java
Set
for(Lead l : Trigger.new) {
if(l.PostalCode != Null) {
zips.add(l.PostalCode);
}
}
for(Lead l : Trigger.new) {
List
for(Region__c r : regions) {
if(l.PostalCode == r.Zip_Code__c) {
l.Region__c = r.Region_Name__c;
}
}
}
The 'most efficient' Apex trigger logic depends on bulkification and strict compliance with Salesforce governor limits. Apex triggers can handle up to 200 records in one batch. If a SOQL query is placed inside a loop, the transaction fails with a System.LimitException once more than 100 records are processed, because the cap is 100 synchronous SOQL queries.
Option A adheres to the widely used 'Bulkify, Query, and Map' design pattern:
Collection: It loops through the input records one time to collect all relevant search criteria (Zip Codes) into a Set.
External Query: It runs a single SOQL query outside of any loop to retrieve every matching Region__c record for the whole batch. This is the most vital step for scalability.
Mapping: It stores the results in a Map<String, String> (Zip Code to Region Name). Maps deliver $O(1)$ constant-time lookup performance.
Final Assignment: It loops through the Leads a second time and sets the Region by using the Map.
Options B, C, and D are all anti-patterns. Option C is the most hazardous, since it runs a query for each individual record. Options B and D are marginally better but still redundant, because they run a query inside a loop that fetches data already retrieved in earlier iterations. Only Option A guarantees the code is efficient, bulk-safe, and remains well within governor limits even under heavy data volumes.
Practice every Plat-Dev-301 question in the full set, each one with its verified answer and a detailed explanation
Get Full AccessWhat the Salesforce Plat-Dev-301 Exam Covers
Exam domains verified against the Official Salesforce Plat-Dev-301 exam guide, last checked December 2026.
Domain 1 Advanced Developer Fundamentals
15%Understand localization and multi-currency features and their coding implications. Learn when to use sharing objects and Apex managed sharing, and how to select appropriate custom metadata and custom settings implementations.
Domain 2 Process Automation, Logic, and Integration
27%Master interactions between declarative and programmatic processes. Develop expertise in Apex triggers, error handling, advanced SOQL, asynchronous Apex, dynamic Apex features, platform events, and integration techniques for both inbound and outbound communication.
Domain 3 User Interface
20%Analyze Apex controllers for Lightning web components and Aura components. Build responsive components across devices, handle error display, communicate between components, and use static resources effectively in Visualforce, LWC, and Aura.
Above Practice Question from this Domain: Q1
Domain 4 Testing, Debugging, and Deployment
20%Apply advanced testing techniques including mocks and stubs for Apex. Debug Lightning components, Visualforce, and JavaScript. Isolate root causes in non-executing code and formulate source-driven deployment processes using appropriate tools.
Domain 5 Performance
18%Identify UI performance issues and mitigation techniques. Optimize query structure for large data volumes. Recognize where asynchronous callouts improve performance and code reuse opportunities. Resolve inefficiencies in sample code.
Plat-Dev-301 Exam FAQ
Common questions about the exam itself
Do I need the Platform Developer I certification before taking Plat-Dev-301?
How hard is Plat-Dev-301 compared to Platform Developer I?
How long should I prepare for Plat-Dev-301?
What is the passing score for Plat-Dev-301?
Does Plat-Dev-301 certification expire?
Can I take Plat-Dev-301 online or do I need to go to a testing center?
What is the biggest difference between Platform Developer II and Architect certifications?
Why do so many people fail Plat-Dev-301 on their first attempt?
What happens if I fail the Plat-Dev-301 exam?
How does Plat-Dev-301 relate to the MuleSoft Developer certification?
Other Salesforce Exams
Free practice questions for more Salesforce certification exams
