Limited-Time Offer: Enjoy 50% Savings! - Ends In 0d 00h 00m 00s Coupon code: 50OFF
Free Exam Questions

Plat-Dev-301 Exam Questions & Answers

Salesforce Certified Platform Developer II  •  Salesforce

161 Questions Updated Sep 2026 99% Pass Rate
Get Full Access

100% money-back guarantee

Sample Plat-Dev-301 Questions

Practice with real exam-style questions, each with the verified correct answer and explanation.

Q1 MultipleChoice

A developer creates a lightning web component to allow a Contact to be quickly entered. However, error messages are not displayed.

HTML

Which component should the developer add to the form to display error messages?12

Correct Answer: A
Explanation:

The lightning-record-edit-form i7s a powerful LWC component that automates record creation and editing. 8It handles field-level security, metadata retrieval, and data persistence automatically. However, for a complete user experience, it requires specific sub-components to handle feedback. While lightning-input-field handles inline validation (like a missing required field), it does not automatically display 'top-level' error messages, such as validation rule failures or system errors returned from the server.

To display these errors, the developer must include the lightning-messages (Option A) component inside the lightning-record-edit-form tags. When a form submission fails, the lightning-messages component automatically catches the error payload returned by the Lightning Data Service and renders it in a user-friendly format at the top of the form (or wherever it is placed).

Option B is not a standard Base Lightning Component name. Options C and D belong to the Visualforce and Aura frameworks, respectively, and cannot be used within a Lightning Web Component template. Including lightning-messages is a required step for any robust implementation of lightning-record-edit-form to ensure users are informed of why a record could not be saved.

Q2 MultipleChoice

What is a benefit of JavaScript remoting over Visualforce Remote Objects?

Correct Answer: A
Explanation:

Visualforce provides two primary ways to perform AJAX-style operations: JavaScript Remoting and Remote Objects. The primary benefit of JavaScript Remoting (Option A) is its ability to execute complex server-side logic.

JavaScript Remoting works by calling an Apex method annotated with @RemoteAction. Because this is a standard Apex method, it can perform advanced calculations, complex SOQL queries with multi-object joins, DML operations across various objects, and even call out to external web services.

In contrast, Remote Objects are purely declarative. They allow you to perform basic CRUD operations (Create, Read, Update, Delete) on a single object directly from JavaScript without writing any Apex. While Remote Objects are easier to set up for simple data entry, they cannot handle 'business logic' (like calculating a discount based on customer history) during the data retrieval process.

Option B and C describe Remote Objects, not Remoting. Option D is a feature of standard Visualforce tags like , but not a specific differentiator for Remoting. Therefore, when your application needs 'brains' on the server, JavaScript Remoting is the superior choice.

Q3 MultipleChoice

Business rules require a Contact to always be created when a new Account is created. What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?

Correct Answer: A
Explanation:

This requirement calls for 'Transactional Atomicity,' meaning either both database operations (Account creation and Contact creation) succeed, or neither is committed to the database. In Apex, each DML statement normally acts as its own individual transaction unless managed by Savepoints.

The correct approach is to use Database.setSavepoint() and Database.rollback() within a try-catch block (Option A). The developer sets a savepoint immediately before the Account is inserted. If the Account is created successfully but the subsequent Contact insertion fails (due to a validation rule, trigger error, or system exception), the code enters the catch block. Within the catch block, the developer executes Database.rollback(sp), which reverts the database to the state it was in before the Account was ever inserted.

Option B is technically similar but 'A' provides the standard programmatic pattern name. Option C (allOrNone=false) only applies to a single list of records in one DML call and cannot link the success of an Account to a Contact. Option D (manual deletion) is an unreliable 'cleanup' strategy that fails if the system crashes or if there are secondary side effects from the initial insertion. Using Savepoints ensures the platform handles the rollback safely and completely.

Q4 MultipleChoice

Given a list of Opportunity records named opportunityList, which code snippet is best for querying all Contacts of the Opportunity's Account?

A.

Java

List contactList = new List ();

Set accountIds = new Set ();

for(Opportunity o : opportunityList){

accountIds.add(o.AccountId);

}

for(Account a : [SELECT Id, (SELECT Id FROM Contacts) FROM Account WHERE Id IN :accountIds]){

contactList.addAll(a.Contacts);

}

B.

20

Java

List contactList = new List ();

for ( Contact c : [SELECT Id FROM Contact WHERE AccountId IN :opportunityList.AccountId ]){

contactList.add(c);

}

Correct Answer: A
Explanation:

22

In Apex, 'bulkification' is the practice of ensuring code can handle multiple records efficiently without hitting governor limits. Snippet A demonstrates the correct bulkified approach for this requirement. It first iterates through the opportunityList to collect all unique AccountId values into a Set. Then, it performs a single SOQL query to retrieve all relevant Accounts and their child Contacts using a subquery (Inner Join). This ensures that the code only consumes one SOQL query regardless of how many opportunities are in the input list.

Snippet B is syntactically incorrect and will fail to compile. In Apex, you cannot use dot-notation (like opportunityList.AccountId) on a List collection to retrieve a set of IDs from its elements. To access the AccountId of records within a list, you must iterate through the list or use a map. Even if corrected to use a proper ID collection, Snippet A is often preferred when you need the relationship context between the Account and its Contacts. Most importantly, Snippet A correctly identifies the need to extract IDs into a separate collection before querying, which is a fundamental requirement for writing scalable Apex. It avoids the 'Query in a loop' anti-pattern and adheres to the platform's execution model.

Q5 MultipleChoice

Given the following code:

Java

for ( Contact c : [SELECT Id, LastName FROM Contact WHERE CreatedDate = TODAY] )

{

Account a = [SELECT Id, Name FROM Account WHERE CreatedDate = TODAY LIMIT 5];

c.AccountId = a.Id;

update c;

}

Assuming there were 10 Contacts and five Accounts created today, what is the expected result?

Correct Answer: A
Explanation:

2

The primary issue in this code snippet is a violation of basic variable assignment rules in Apex when dealing with SOQL results. In the line Account a = [SELECT Id, Name FROM Account ... ], the code attempts to assign the result of a query directly 3to a single SObject variable (Account a).

In Apex, a SOQL query assigned to a single SObject variable must return exactly one record. If the query returns zero records, it throws a System.QueryException: List has no rows for assignment. If the query returns more than one record, it throws a System.QueryException: List has more than one row for assignment (Option A). Since the prompt explicitly states that five Accounts were created today and the query is not filtered to a single unique ID, the query will return five records. Even though there is a LIMIT 5 clause, that only caps the results at five; it does not ensure only one is returned. To fix this, the result should be assigned to a List<Account> or the query should be filtered to return exactly one row.

While the code also violates the 'SOQL in a loop' best practice, it would not hit the LimitException (Option C) in this specific case because the loop only runs 10 times (10 contacts), and the limit is 100 queries. The runtime assignment error occurs before any governor limits are breached.

Get access to all 161 verified questions with detailed answers.

Unlock All Plat-Dev-301 Questions

Frequently Asked Questions

You must hold a current Salesforce Certified Platform Developer I certification before attempting the Plat-Dev-301 exam. Additionally, Salesforce recommends having at least 2 years of experience developing custom applications on the Salesforce platform using Apex, Visualforce, Lightning components, and APIs.

The exam contains 60 multiple-choice questions that must be completed within 120 minutes. You need to achieve a score of 70% or higher to pass the certification exam.

The exam covers advanced topics including asynchronous Apex, batch processing, schedulable interfaces, web services integration, custom metadata types, and complex security implementations. It also includes Lightning web components, advanced SOQL/SOSL queries, and application architecture patterns.

The Salesforce Certified Platform Developer II certification is valid for three years from the date you pass the exam. After three years, you must retake the certification exam or pass a renewal exam to maintain your active certification status.

Salesforce recommends using official study materials including the Platform Developer II exam guide, Trailhead modules, official study groups, and practice exams. Many candidates also find it helpful to review the Salesforce documentation, take advanced Apex courses, and gain hands-on experience with the technologies covered on the exam.
Exam Details
  • Exam CodePlat-Dev-301
  • VendorSalesforce
  • Total Questions161
  • LanguageEnglish
  • Last UpdatedSep 5, 2026
4.9/5

Pass Plat-Dev-301 First Time

Get all 161 exam questions with verified answers and 90-day free updates.

Buy Now & Pass
  • PDF + Practice Test Bundle
  • 90-Day Free Updates
  • 100% Money-Back Guarantee
  • Instant Download
  • 24/7 Customer Support
99% Pass Rate Trusted by 50,000+ IT professionals