Salesforce certification · Exam Salesforce-Platform-Developer

Salesforce-Platform-Developer Mock Exam

Salesforce Platform Developer - Plat-Dev-201

Free Salesforce-Platform-Developer questions on Developer Fundamentals, each with the answer and an explanation.

20 questions · 35 minutes · free, no sign-up

Developer Fundamentals questions

1–9 of 9 free
Question 1 Choose 1
Universal Containers wants a list button to display a Visualforce page that allows users to edit multiple records. Which Visualforce feature supports this requirement?
Show answerHide answer

Correct answer: D Standard controller and the recordSetVar page attribute

Explanation

Explanation:

Why D is correct:
To build a Visualforce page capable of handling, displaying, and editing a list of multiple records, such as when launching from a list view action button, developers use a Standard Controller combined with the recordSetVar attribute. The recordSetVar attribute defines a collection or set of records, turning the standard controller into a Standard Set Controller, which natively supports multi-record selection, iteration components such as , and bulk updates.

Why the other options are incorrect:

A & B:
A "Custom List Controller" is not a native framework feature. Standard list management is handled natively through the built-in standard controller coupled with recordSetVar.

C:
A plain standard controller without recordSetVar only manages a single record context at a time, making it impossible to process multiple records from a list view button without the collection variable.

References
Visualforce Developer Guide: Editing Records with List Controllers
Question 2 Choose 1
A lead developer creates a virtual class called "OrderRequest". Consider the following code snippet:
public class CustomerOrder{
//code implementation
}
How can a developer use the OrderRequest class within the CustomerOrder class?
Show answerHide answer

Correct answer: B public class CustomerOrder extends OrderRequest

Explanation

Explanation:

Why B is correct:
In Apex object-oriented programming, when a class wants to inherit from a virtual or abstract class, it uses the extends keyword. Because OrderRequest was defined as a virtual class, CustomerOrder can extend it to inherit its fields, methods, and behavior.

Why the other options are incorrect:

A. implements:
The implements keyword is used when a class implements an interface, not when inheriting from a virtual class.

C & D. @Extends / @Implements annotations:
Apex does not use annotations for inheritance or interface implementation. It uses native language keywords, such as extends and implements.

References
Salesforce Apex Developer Guide: Inheritance (Virtual and Abstract Classes)
Question 3 Choose 2
What are two benefits of using External IDs? Choose 2 answers
Show answerHide answer

Correct answer: A, D An External ID field can be used Co reference an ID from another external system.An External ID is indexed and can improve the performance of SOQl quenes.

Explanation

Explanation:

🟒 Correct Answer: A. An External ID field can be used to reference an ID from another external system.
This is a primary use case for External IDs. When you are integrating Salesforce with an external system, you often need to store the unique identifier from that system on the Salesforce record. By marking a field as an External ID, you can use its value to upsert records (update existing records or insert new ones) without having to know the Salesforce ID (the 15 or 18-character ID). This is crucial for data loading and integration scenarios where the external system's ID is the key to matching records.

🟒 Correct Answer: D. An External ID is indexed and can improve the performance of SOQL queries.
Salesforce automatically creates an index on fields marked as an External ID. An index is a data structure that improves the speed of data retrieval operations on a database table. Therefore, using an External ID in the WHERE clause of a SOQL query will be significantly faster than querying a non-indexed field. This is particularly important for large data sets, as it helps avoid timeouts and improves overall application performance. While other fields can be indexed, the External ID designation is a simple way to ensure a field is indexed for this purpose.

πŸ”΄ Incorrect Answer: B. An External ID can be a formula field to help create a unique key from two fields in Salesforce.
Reasoning: This is incorrect because a field designated as an External ID must be a writable field type, such as Text, Number, or Email. Formula fields are read-only and their values are calculated dynamically at runtime. As such, they cannot be used for matching or upserting records via an external key, which is a key function of an External ID. You cannot select the "External ID" checkbox for a formula field when you are creating or editing the field in Salesforce.

πŸ”΄ Incorrect Answer: C. An External ID can be used with Salesforce Mobile to make external data visible.
Reasoning: While you can use External IDs in some integration scenarios with Salesforce Mobile, the primary function of an External ID is for record matching and data synchronization, not for making external data visible. The Salesforce feature specifically designed to display data from external systems in real-time, within the Salesforce user interface, is Salesforce Connect. This feature uses External Objects and External Data Sources to present the data, which is a different concept from a field's External ID attribute.

Reference:
For further information on External IDs and their capabilities, you can refer to the official Salesforce documentation on "Custom Field Attributes" and "External IDs." This resource details the supported field types for External IDs and explains their purpose in data integration and performance.
Source: Salesforce Help: Custom Field Attributes
Question 4 Choose 1
A developer created this Apex trigger that calls Myclass.myStaticMethod:


The developer creates a test class with a test method that calls MyClass.myStaticMethod directly, resulting in 81% overall code coverage. What happens when the developer tries to deploy the trigger and two classes to production, assuming no other code exists?
Show answerHide answer

Correct answer: D The deployment fails because the Apex trigger has no code coverage.

Explanation

Explanation:

Salesforce requires that each Apex trigger is covered by at least 1% code coverage to deploy to production. In your case:

The test method directly calls MyClass.myStaticMethod, which covers the method in the class.
However, the trigger itself is not executed by the test, so the trigger has 0% coverage.
Even though the total coverage is over 75%, individual triggers must have at least some coverage (β‰₯1%).
Question 5 Choose 1
Which statement should be used to allow some of the records in a list of records to be inserted if others fail to be inserted?
Show answerHide answer

Correct answer: A Database.insert (records, false)

Explanation

Explanation:

Salesforce provides two ways to perform DML operations:

βœ… DML statements (insert records) β†’ If one record fails, the entire operation is rolled back.
βœ… Database methods (Database.insert(records, false)) β†’ Allows partial success, meaning successful records are inserted, while failed ones are skipped without rolling back the whole operation.

Why Database.insert(records, false) Works Best?

The second parameter (false) specifies that the operation should allow partial success.
Records that pass validation are inserted, while failing ones do not prevent other inserts.
The method returns a Database.SaveResult array, allowing developers to identify failed records and handle errors gracefully.
Question 6 Choose 1
Developers at Universal Containers (UC) use version control to share their code changes, but they notice that when they deploy their code to different environments they often have failures. They decide to set up Continuous Integration (CI). What should the UC development team use to automatically run tests as part of their CI process?
Show answerHide answer

Correct answer: B Salesforce CLI

Explanation

Explanation:

- Salesforce CLI (SFDX CLI) is the best tool for automating tests in a CI/CD pipeline.
- It allows developers to run Apex tests using commands like:

sfdx force:apex:test:run -u sandboxAlias
- This ensures automated testing is integrated into the development workflow, reducing deployment failures.

❌ Why the other options are incorrect:
A. Force.com Toolkit

❌ Outdated and not suitable for modern CI/CD.
Not actively maintained or recommended by Salesforce.

C. Visual Studio Code

❌ It's an IDE, not a CI tool.
Used for local development but not for automating test execution.
D. Developer Console
❌ Only useful for manual testing and debugging.
Cannot be used in a CI pipeline or for automated deployments.

Key Takeaways:
βœ… Salesforce CLI (B) is the only tool designed for automated testing in CI.
🚫 Avoid legacy (A) or manual (D) tools.
Question 7 Choose 1
Consider the following code snippet:


Given the multi-tenant architecture of the Salesforce platform, what Is a best practice a developer should Implement and ensure successful execution of the method?
Show answerHide answer

Correct answer: D Avoid performing queries inside for loops.

Explanation

Explanation:

The provided Apex code performs a SOQL query inside a for loop, which is a well-known anti-pattern in Salesforce development due to its governor limits.

In this code:

for (Id leadId : leadIds) {
result.add([SELECT FIELDS(ALL) FROM Lead WHERE Id = :leadId]);
}

A SOQL query is executed once for each lead ID.

If leadIds contains more than 100 items, it exceeds the governor limit of 100 SOQL queries per transaction, causing a runtime exception.

πŸ”§ Best Practice Fix:

Use bulk querying instead of querying inside the loop:

public static List obtainAllFields(Set leadIds) {
return [SELECT FIELDS(ALL) FROM Lead WHERE Id IN :leadIds];
}

This executes just one query, no matter how many IDs are passed in.

❌ Why other options are incorrect:

A. Avoid executing queries without a limit clause
Not necessary when querying by specific IDs β€” the ID filter already limits the result.

B. Avoid returning an empty List of records
Returning an empty list is safe and standard if no records match β€” not a best practice violation.

C. Avoid using variables as query filters
Using variables (e.g., :leadIds) is best practice for dynamic and safe queries β€” this option is incorrect.
Question 8 Choose 1
Which annotation exposes an Apex class as a RESTful web service?
Show answerHide answer

Correct answer: C

Explanation

Explanation:

The @RestResource annotation is used to expose an Apex class as a RESTful web service in Salesforce.
It allows you to define a custom REST endpoint
You can handle HTTP methods like GET, POST, PUT, and DELETE
You specify the URL path using urlMapping

πŸ” Example:

@RestResource(urlMapping='/myService/*')
global with sharing class MyRestService {
@HttpGet
global static String doGet() {
return 'Hello from REST!';
}
}

❌ Why the other options are incorrect:

A. @AuraEnabled(cacheable=true)
❌ Used to expose methods to Lightning components (LWC, Aura), not RESTful services

B. @RemoteAction
❌ Used to expose Apex methods to Visualforce + JavaScript remoting, not REST

D. @HttpInvocable
❌ Not a valid Apex annotation (possibly confused with @InvocableMethod, which is used for Flows)
Question 9 Choose 1
Which Apex class contains methods to return the amount of resources that have been used for a particular governor, such as the number of DML statements?
Show answerHide answer

Correct answer: D Limits

Explanation

Explanation:

The Limits Apex class provides methods to monitor and retrieve the governor limits that apply to the current execution context in Salesforce.
It helps developers write efficient code by allowing them to check how many resources (like DML statements, SOQL queries, etc.) have been used or are remaining.

πŸ” Example methods from Limits class:

Limits.getDmlStatements() β†’ Returns the number of DML statements used so far.
Limits.getLimitDmlStatements() β†’ Returns the maximum allowed DML statements (usually 150).
Limits.getQueries() β†’ Number of SOQL queries used.
Limits.getLimitQueries() β†’ SOQL query limit.

❌ Incorrect Options:

A. Exception
Used for handling runtime errors, not governor limits.

B. Messaging
Used for email services, like sending emails, not monitoring system limits.

C. OrgLimits
Deals with org-wide limits (e.g., total API calls per org), not per-transaction governor limits.

That's the last free question in Developer Fundamentals

You've seen the free 30% (9 of 33 questions). Full access unlocks every question and full-length Salesforce-Platform-Developer mock exams (60 questions, 105 minutes), a different mock on every attempt.

Unlock full mock exam
Full mock exam

Sit the Salesforce-Platform-Developer exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real Salesforce-Platform-Developer exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full Salesforce-Platform-Developer mock exam
  • 60questions per mock
  • 105 mintime limit
  • 184questions in the bank
  • Newmock on every attempt