Salesforce Certified Platform Developer I Free Sample Questions

Description

Covers declarative process automation and Apex fundamentals, Visualforce and Lightning Components, platform and data modeling fundamentals, and the testing, debugging and deployment framework.

20 free sample questions200 in the full practice test Other versions: Plat-Dev-201(166),DEV-450(169)

Try simulator

PDI Sample Questions

  1. Question 1

    Intermediate

    Process Automation and Logic · Apex Triggers vs. Declarative Automation

    A financial services company has a requirement to prevent the deletion of any Opportunity record with a 'Closed Won' status by any user except those with a 'System Administrator' profile. A junior developer suggests creating a validation rule. As the senior developer, what is the most robust and secure approach to meet this requirement?

    Answer and explanation

    Correct answer: B

    The most robust solution is an Apex trigger on the 'before delete' event. Validation rules do not fire on delete operations, so they cannot be used to prevent record deletion. A 'before delete' trigger can inspect the records being deleted, check the user's profile, and use the .addError() method on the records that should not be deleted, effectively blocking the DML operation. This approach is secure and directly addresses the requirement which cannot be met by declarative tools.

  2. Question 2

    Intermediate

    User Interface · Visualforce Controllers and Components

    A developer needs to create a Visualforce page that displays a list of Contact records. The page should allow users to select multiple contacts via checkboxes and then perform a bulk update on a custom field, Status__c, for all selected records. Which combination of Visualforce components and controller logic is best suited for this requirement?

    Answer and explanation

    Correct answer: A

    The best approach is to use a wrapper (or inner) class within a custom controller. The wrapper class will contain the Contact sObject and a boolean property to track the checkbox state. The Visualforce page will iterate over a list of these wrapper objects in an or . This pattern allows the controller to easily identify which records were selected when the user submits the form, enabling efficient bulk processing.

  3. Question 3

    Advanced

    Testing, Debugging, and Deployment · Testing Asynchronous and Callout Logic

    A developer is writing a test class for an Apex trigger that fires on after update of Account records. The trigger makes a callout to an external service. The test method fails with an System.CalloutException: You have uncommitted work pending. error. The developer has already implemented a mock callout. What is the cause of this error in a test context?

    Answer and explanation

    Correct answer: B

    Salesforce prevents performing a callout after a DML operation within the same transaction to avoid data integrity issues. Even in a test context with mock callouts, this rule is enforced. The DML statement (update account;) starts a transaction that is not committed until the test method finishes. The after update trigger attempts the callout within this transaction, causing the 'uncommitted work pending' error. To resolve this, the callout logic must be moved to an asynchronous method (like a @future method), and the test must use Test.startTest() and Test.stopTest() to ensure the DML is committed before the asynchronous logic executes.

  4. Question 4

    Intermediate

    Developer Fundamentals · Data Modeling and Relationship Types

    A university is building a student management application. They have custom objects for Student__c, Course__c, and Enrollment__c. A student can enroll in many courses, and a course can have many students. The Enrollment__c object represents a student's enrollment in a specific course and contains details like Grade__c and Semester__c. When a Student__c record is deleted, all their related Enrollment__c records must also be deleted. Which data model correctly represents this relationship?

    Answer and explanation

    Correct answer: C

    This scenario describes a many-to-many relationship between Student and Course, implemented with Enrollment__c as the junction object. The requirement that enrollments are deleted when a student is deleted indicates a cascading delete behavior, which is a key feature of a Master-Detail relationship. Therefore, Enrollment__c must have a Master-Detail relationship to Student__c. The relationship to Course__c can be a Lookup, as there's no stated requirement for cascading deletion when a course is deleted. An object can have at most two master-detail relationships, but in this case, only one is strictly required by the prompt, making this the most appropriate and common configuration.

    erDiagram STUDENT ||--|{ ENROLLMENT : has COURSE ||..|{ ENROLLMENT : has STUDENT { string Id PK string Name } COURSE { string Id PK string CourseName } ENROLLMENT { string Id PK string StudentId FK "Master-Detail" string CourseId FK "Lookup" string Grade__c }

  5. Question 5

    IntermediateMultiple answers

    Process Automation and Logic · Asynchronous Apex and Batch Jobs

    A developer is tasked with creating a nightly batch job that processes all Order__c records marked as 'Pending Fulfillment'. The job must aggregate line items for each order, calculate a total shipping weight, and update a Total_Weight__c field on the Order__c record. The org contains millions of Order__c records. Which Apex features are essential for building a scalable and efficient solution? (Select THREE)

    Answer and explanation

    Correct answers: A, D, E

    To process millions of records, Batch Apex (using the Database.Batchable interface) is the correct choice as it processes records in manageable chunks, respecting governor limits. To run the job nightly, the class must also implement the Schedulable interface. Within the start method of the batch class, a Database.QueryLocator must be used to build the scope of records to process. A QueryLocator can handle up to 50 million records, making it essential for large data volumes.

  6. Question 6

    Beginner

    User Interface · Lightning Component Framework

    A developer is building a custom Aura component that needs to display a list of related Case records on an Account record page. To optimize performance, the developer wants to fetch the data from the server only when the component is first rendered. Where should the developer place the call to the Apex controller method to fetch the case data?

    Answer and explanation

    Correct answer: B

    The standard practice for fetching data when an Aura component initializes is to use the aura:handler for the init event. The handler, typically named doInit, is defined in the component markup: . The corresponding doInit function in the component's JavaScript controller should then call a function in the helper to make the server-side call to the Apex method. Placing logic in the helper promotes code reuse and better organization.

  7. Question 7

    Beginner

    Testing, Debugging, and Deployment · Developer Console and SOQL Limits

    A developer uses the Developer Console to execute a SOQL query. The query returns 50,001 rows from the Account object. What will be the outcome?

    Answer and explanation

    Correct answer: B

    The total number of records that can be retrieved by a single SOQL query is 50,000. This is a hard governor limit enforced by the platform. Attempting to retrieve 50,001 rows in a single query, whether in Apex, the Developer Console, or another tool, will result in a System.LimitException indicating that the query has retrieved too many rows.

  8. Question 8

    Intermediate

    Process Automation and Logic · Apex Security and Sharing

    True or False: Using the with sharing keyword on an Apex class guarantees that a user can only see records they have explicit access to via sharing rules, regardless of their object-level permissions.

    Answer and explanation

    Correct answer: B

    False. The with sharing keyword enforces the sharing rules for the current user, but it does NOT enforce object-level or field-level security. A user must have at least 'Read' permission on the object to see any records at all. If a user has 'Read' permission on the object, with sharing will then filter the records returned by a query based on the user's record-level access (sharing rules, role hierarchy, etc.).

  9. Question 9

    Beginner

    Process Automation and Logic · SOQL Relationship Queries

    A developer needs to write a SOQL query to retrieve Account records along with all of their related Contact records. The query should be executed within an Apex class. What is the correct syntax for this parent-to-child query?

    Answer and explanation

    Correct answer: B

    The correct syntax for a parent-to-child subquery uses the plural child relationship name. For standard objects, this is typically the plural of the child object name (e.g., Contacts, Opportunities). For custom objects, the relationship name is the plural of the child object name appended with __r (e.g., My_Custom_Objects__r).

  10. Question 10

    Beginner

    Developer Fundamentals · Declarative Features

    A retail company uses a custom Shipment__c object that has a Master-Detail relationship with the standard Account object. A developer needs to create a field on the Account object that displays the date of the most recent Shipment__c record. What is the most efficient way to implement this without writing any Apex code?

    Answer and explanation

    Correct answer: A

    Roll-Up Summary Fields are a declarative feature that can perform calculations like COUNT, SUM, MIN, and MAX on records in a detail relationship. Since Shipment__c has a Master-Detail relationship to Account, a Roll-Up Summary Field can be created on the Account object. Using the MAX function on the shipment date field will efficiently find and display the date of the most recent shipment without needing Apex.

Register free for 10 more questions

Or unlock all 200 PDI questions with explanations, timed mode and flashcards.