Salesforce Plat-Dev-201 Practice Exam Questions & Answers
Salesforce Plat-Dev-201 Exam Details
Key details for this exam, checked against the published exam outline
- Exam Code
- Plat-Dev-201
- Full Name
- Salesforce Certified Platform Developer
- Issuing Body
- Salesforce
- Question Format (Our Bank)
- Multiple Choice
- Full Question Set
- 204 questions Get All Questions
Free Plat-Dev-201 Practice Questions
Each question shows the correct answer and an explanation of why it is right
Question 1 Domain 4 Testing, Debugging, and Deployment
What method allows a developer to verify test coverage for autolaunched Flows prior to including them in a change set deployment?
Before deployment, developers can verify coverage for autolaunched flows by running SOQL queries against the Tooling API. This approach returns granular data showing which flows are covered and the results of their tests.
Question 2 Domain 2 Process Automation and Logic
Suppose name is a String retrieved from a Visualforce page. Which two SOQL queries below are protected against SOQL injection? (Choose two.)
Detailed Explanation From Official Extract: To work out which SOQL queries are shielded from SOQL injection, each option has to be checked for how it handles the name parameter (user input arriving from a Visualforce page) and whether it actually lowers the risk of injection. SOQL injection takes place when untrusted user input is placed directly into a query string, which allows a malicious user to alter the logic of the query. Each option is reviewed below using Salesforce's official documentation, particularly the Secure Coding Guidelines and the Apex Developer Guide.
Understanding SOQL Injection:
SOQL Injection: This weakness appears when user input is dynamically joined into a SOQL query string without being cleaned first, so an attacker can change how the query behaves. For instance, if name is ' OR '1'='1, an unsafe query could return every record instead of the intended subset. The Salesforce Secure Coding Guidelines explain that an attacker can get around the intended logic whenever untrusted input is joined onto a query string (Salesforce Secure Coding Guidelines, SOQL Injection).
Prevention Techniques:
Bind Variables (:variable): Binding a variable in a SOQL query treats user input as a value rather than as part of the query logic, which stops injection. The Apex Developer Guide points out that bind variables (:variable) are the most reliable way to guard against SOQL injection (Salesforce Apex Developer Guide, Secure Coding for SOQL).
Sanitization: When dynamic SOQL such as Database.query() is required, user input should be cleaned with a method like String.escapeSingleQuotes(), which escapes special characters (for example, single quotes) that could change the query.
Context: The name variable is obtained from a Visualforce page, so it is untrusted user input and must be handled with care to prevent injection.
Evaluating the Options:
A.
apex
Copy
String query = '%' + name + '%';
List<Account> results = [SELECT Id FROM Account WHERE Name LIKE :query];
Approach: Builds a string by joining the % wildcards to the name variable, then references that string through a bind variable (:query) inside the SOQL query.
Security: Because a bind variable (:query) is used, the value of query (which contains name) is handled as a literal value in the LIKE clause rather than as query syntax. Even if name holds malicious input (for example, ' OR '1'='1), the SOQL engine treats it as one string to compare against Name, so injection is prevented. The Apex Developer Guide confirms that bind variables stop SOQL injection by handling user input as data and never as executable code (Salesforce Apex Developer Guide, Secure Coding for SOQL).
Example: If name = 'Test' OR '1'='1, then query = '%Test' OR '1'='1%'. The SOQL query becomes:
apex
Copy
[SELECT Id FROM Account WHERE Name LIKE '%Test\' OR \'1\'=\'1%']
This searches for records whose Name matches the literal text %Test' OR '1'='1%, which is safe and leaves the query logic unchanged.
Conclusion: Safe from SOQL injection because it uses a bind variable.
B.
apex
Copy
String query = 'SELECT Id FROM Account WHERE Name LIKE \'%' + name.noQuotes() + '%\'';
List<Account> results = Database.query(query);
Approach: Creates a dynamic SOQL string by joining name.noQuotes() into the query, then runs it with Database.query().
Security: The noQuotes() method is not a standard method of the Apex String class. The Apex Developer Guide does not document noQuotes() as a built-in (Salesforce Apex Developer Guide, String Class). If it is a custom method, it probably tries to strip quotes from the string, but that does not stop SOQL injection. Placing user input directly into the query string is inherently unsafe unless it is properly sanitized.
Example: If name = 'Test' OR '1'='1, and noQuotes() changes nothing (or only removes quotes, which does not help), the query becomes:
apex
Copy
SELECT Id FROM Account WHERE Name LIKE '%Test' OR '1'='1%'
The OR '1'='1' condition is true for every record, so all Accounts are returned, which is a successful SOQL injection attack.
Conclusion: Not safe. It joins user input straight into the query without proper sanitization or bind variables, and noQuotes() is neither a standard nor a dependable defense against injection.
C.
apex
Copy
String query = 'SELECT Id FROM Account WHERE Name LIKE \'%' + String.escapeSingleQuotes(name) + '%\'';
List<Account> results = Database.query(query);
Approach: Creates a dynamic SOQL string by joining name to the query after passing it through String.escapeSingleQuotes(), then runs it with Database.query().
Security: String.escapeSingleQuotes() adds a backslash (\) in front of each single quote in the input, which stops the input from escaping the string literal in the SOQL query. The Apex Developer Guide says that String.escapeSingleQuotes() guards against SOQL injection in dynamic queries by escaping single quotes so the input cannot change the query structure (Salesforce Apex Developer Guide, String Class). As a result, even malicious input cannot alter the query logic.
Example: If name = 'Test' OR '1'='1, then String.escapeSingleQuotes(name) returns Test\' OR \'1\'=\'1. The query becomes:
apex
Copy
SELECT Id FROM Account WHERE Name LIKE '%Test\' OR \'1\'=\'1%'
This searches for records whose Name matches the literal text %Test' OR '1'='1%, which is safe because the OR condition is never run as logic.
Conclusion: Safe from SOQL injection because String.escapeSingleQuotes() cleans the user input used in the dynamic query.
D.
apex
Copy
String query = 'SELECT Id FROM Account WHERE Name LIKE \'%' + name + '%\'';
List<Account> results = Database.query(query);
Approach: Creates a dynamic SOQL string by joining name straight into the query, then runs it with Database.query().
Security: This approach is open to SOQL injection because name is placed directly into the query string with no sanitization. The Salesforce Secure Coding Guidelines caution that joining user input directly into a dynamic SOQL query without escaping can enable SOQL injection (Salesforce Secure Coding Guidelines, SOQL Injection).
Example: If name = 'Test' OR '1'='1, the query becomes:
apex
Copy
SELECT Id FROM Account WHERE Name LIKE '%Test' OR '1'='1%'
The OR '1'='1' condition is true for every record, so all Accounts are returned, which demonstrates a successful SOQL injection attack.
Conclusion: Not safe. It joins user input directly without sanitization or bind variables.
Why Options A and C are Correct:
Option A: Uses a bind variable (:query) in the SOQL query, so the user input (name) is handled as a literal value and never as executable code. Salesforce recommends this as the most secure way to prevent SOQL injection.
Option C: Uses String.escapeSingleQuotes() to clean the user input before it is placed into a dynamic SOQL query, which keeps the input from changing the query's logic. This is a safe approach for dynamic queries when a bind variable cannot be used directly.
Options B and D: Both join user input straight into the query string without adequate sanitization (noQuotes() is not a standard or dependable method in B, and D has no sanitization at all), so both are vulnerable to SOQL injection.
Example of Vulnerability (Option D):
Consider a Visualforce page where name is set from a user input field:
apex
Copy
String name = ApexPages.currentPage().getParameters().get('name');
String query = 'SELECT Id FROM Account WHERE Name LIKE \'%' + name + '%\'';
List<Account> results = Database.query(query);
If a malicious user submits name = ' OR '1'='1, the query becomes:
apex
Copy
SELECT Id FROM Account WHERE Name LIKE '%' OR '1'='1%'
This returns every Account and bypasses the intended filtering, which is a successful SOQL injection attack.
Mitigating SOQL Injection:
Preferred (Option A): Use bind variables whenever possible:
apex
Copy
String query = '%' + name + '%';
List<Account> results = [SELECT Id FROM Account WHERE Name LIKE :query];
Alternative (Option C): If dynamic SOQL is needed, clean the input with String.escapeSingleQuotes():
apex
Copy
String query = 'SELECT Id FROM Account WHERE Name LIKE \'%' + String.escapeSingleQuotes(name) + '%\'';
List<Account> results = Database.query(query);
Handling Typos:
The options are syntactically correct in the provided image, so there are no typos to address.
Option B's name.noQuotes() is not a standard Apex method, but the analysis treats it as a custom method that fails to prevent injection, since it is not a recognized sanitization technique.
Salesforce Apex Developer Guide:
''Secure Coding for SOQL'' section: Recommends bind variables to prevent SOQL injection.
''String Class'' section: Explains String.escapeSingleQuotes() for cleaning dynamic queries.
''Database Class'' section: Describes Database.query() for running dynamic SOQL. (Available at: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/)
Salesforce Secure Coding Guidelines:
''SOQL Injection'' section: Cautions against joining untrusted input into queries and recommends bind variables or sanitization. (Available at: https://developer.salesforce.com/docs/atlas.en-us.secure_coding_guide.meta/secure_coding_guide/)
Platform Developer I Study Guide:
Section on ''Salesforce Platform and Declarative Features'': Covers secure coding practices, including preventing SOQL injection in Visualforce contexts. (Available at: https://trailhead.salesforce.com/en/content/learn/modules/platform-developer-i-certification-study-guide)
Question 3 Domain 3 User Interface
Which two places can a developer check to monitor the state of batch or future methods?
Select 2 answers
Option A (Developer Console):The Developer Console offers an in-depth look at execution logs and the state of Apex batch or future methods.
Option B (Apex Jobs):The Apex Jobs page in Salesforce Setup displays the state of queued, running, or finished batch and scheduled jobs.
Incorrect Options:
C (Paused Flow Interviews):Applies solely to paused flows, not to batch or future jobs.
D (Apex Flex Queue):Serves to manage the order in which batch jobs execute, not to track job status.
Get the complete Plat-Dev-201 question set
$20$40
Question 4 Domain 3 User Interface
A developer has written Apex code that makes a callout to an external system by means of the REST API.
Which approach should the developer take to write a test that verifies the code works as intended?
Salesforce offers the HTTPCalloutMock interface for testing Apex that performs HTTP callouts. A developer builds a test class that implements HTTPCalloutMock in order to specify the simulated response returned when the callout runs during the test.
As a result, the tests do not rely on whether the external system is available or how it behaves.
Why not other options?
B and C: Neither is relevant when testing HTTP callouts.
D: HTTPCalloutMock cannot be extended. It is implemented instead.
:
Apex Testing for HTTP Callouts
Question 5 Domain 2 Process Automation and Logic
Universal Containers has adopted a private sharing model for the Account object. A bespoke Account search utility was built in
Apex so sales staff can locate accounts that satisfy several criteria they enter. After going live, people using the utility report that they are able to view
Accounts they are not the owner of.
Which mechanism should the developer apply to make the custom search tool enforce the sharing permissions of the currently logged in user?
Declaring the class with the with sharing keyword makes the Apex class honor the sharing rules applying to the current user, including the private sharing model. As a result, the logged-in user only sees records they own or that have been shared with them.
Incorrect Options:
B: Using without sharing disregards sharing rules, which exposes data the user has no right to access.
C: Filtering with userInfo is neither a scalable nor a maintainable approach.
D: Schema describe calls do not enforce sharing permissions and only verify object-level access.
Question 6 Domain 1 Developer Fundamentals
Universal Containers' sales management team needs the Lead Source field on the Lead record to be filled in whenever a Lead is converted. Which approach should be used so that users must populate the Lead Source field before they convert a Lead?
A validation rule can make sure the Lead Source field is filled in before a Lead is converted. This stops users from moving forward until the required information has been entered.
Why are the other options incorrect?
A: Triggers are written in code, while a declarative tool such as a validation rule is simpler and more efficient.
B: Lead Conversion field mapping maps values from Lead to Account and Contact, but it cannot require that a field be completed.
C: A formula field is read-only and cannot require user input.
:
Validation Rules Documentation
Question 7 Domain 1 Developer Fundamentals
Universal Containers needs new cases to be routed automatically to the right support representative according to each case's origin. A custom field has been added to the Case object to hold the name of the support representative.
Which approach is the most suitable for assigning each case to the correct support representative?
A Flow containing an Assignment element is the most suitable declarative approach for routing cases according to criteria such as Case Origin. It can automatically check the Case Origin value and set the support representative accordingly.
Why are the other options incorrect?
A: Writing a trigger is a programmatic method, which is less appropriate when declarative tools can handle the requirement.
B: A formula field cannot set values; it can only calculate and display results.
C: Validation rules exist to enforce restrictions, not to assign values.
:
Salesforce Flows Overview
Question 8 Domain 2 Process Automation and Logic
Universal Containers owns many bespoke applications created with a third-party JavaScript framework and delivered through Visualforce pages. The business wants these applications restyled so they resemble the look and feel of Lightning Experience.
What should the developer do to meet this business need as quickly and effectively as possible?
The fastest way to give Visualforce pages a Lightning Experience appearance is to add SLDS. This delivers consistent styling without rebuilding the applications.
Why not other options?
A: Converting all Visualforce pages into Lightning components takes a lot of time and is not efficient.
B: The attributeenableLightningin does not exist in Visualforce.
C: Turning on Lightning Experience compatibility does not automatically apply styling.
:
Salesforce Lightning Design System (SLDS)
What the Salesforce Plat-Dev-201 Exam Covers
Exam domains verified against the Official Salesforce Plat-Dev-201 exam guide, last checked November 2026.
Domain 1 Developer Fundamentals
27%Understand multi-tenant concepts and design frameworks such as MVC architecture and Lightning Component Framework. Learn to identify common use cases and best practices for choosing between declarative and programmatic customizations, including how to work with governor limits, formula fields, and roll-up summaries.
Domain 2 Process Automation and Logic
28%Master declarative process automation features and Apex language fundamentals including variables, constants, methods, and interfaces. Write and optimize SOSL, SOQL, and DML statements while understanding governor limits, transaction execution, exception handling, and best practices for triggers and classes.
Domain 3 User Interface
25%Prevent security vulnerabilities in user interfaces and data access controls. Build custom UI components using Lightning Web Components, Flow, and Visualforce, and implement Apex to work effectively with various page components including Lightning components, Flow, and Agentforce.
Domain 4 Testing, Debugging, and Deployment
20%Write and execute comprehensive tests for triggers, controllers, classes, and flows using various test data sources. Use Salesforce Developer tools like Salesforce DX, Salesforce CLI, and Developer Console, then approach debugging and deployment with knowledge of environments, requirements, and processes.
Sample question from this domain above Q1
Plat-Dev-201 Exam FAQ
Common questions about the exam itself
What background and experience do I need before taking Plat-Dev-201?
How difficult is the Plat-Dev-201 exam and what makes it challenging?
How long does it typically take to prepare for Plat-Dev-201?
What happens on exam day for Plat-Dev-201 and how is it scored?
What are the retake and rescheduling rules for Plat-Dev-201?
How long is the Salesforce Certified Platform Developer certification valid?
Which Salesforce job role does Plat-Dev-201 certification map to?
How does Plat-Dev-201 relate to other Salesforce developer exams?
What is the biggest area where candidates struggle on Plat-Dev-201?
Is there a prerequisite certification or experience requirement to sit Plat-Dev-201?
Other Salesforce Exams
Free practice questions for more Salesforce certification exams
