PDI Practice Questions
Prepare for PDI with more than an answer.
Unlock the full exam and previous versions
- v1Salesforce Certified Platform Developer I 166 questions Locked
- DEV-450Legacy Salesforce Certified Platform Developer I 169 questions Locked
- PDILegacy Salesforce Certified Platform Developer I 200 questions Current
- Exam fee
- $200 USD
- Level
- Professional
- Valid for
- Must complete maintenance modules annually
Domains covered on the exam 4
- Process Automation and Logic30%
- User Interface25%
- Developer Fundamentals23%
- Testing, Debugging, and Deployment22%
- 1
Case Study: Universal Containers (UC) is implementing a new quality assurance (QA) process. They have a custom object,
QA_Review__c, which has a lookup relationship to theCaseobject. The QA team needs a central place to view all Cases with their associated QA Reviews.The business has provided the following requirements:
- A Visualforce page must be created to display a list of all Cases.
- For each Case in the list, the user should be able to see the
Status__candScore__cfrom the most recent relatedQA_Review__crecord. - The solution must be performant and not exceed governor limits, even with thousands of Cases.
- The page should be accessible via a custom tab.
A developer needs to design the Apex controller to support this Visualforce page. Which approach for fetching and structuring the data is most efficient and scalable?
Show answer details
Correct answer: D
The most efficient approach is to offload as much processing as possible to the database. A single aggregate SOQL query can retrieve all the necessary information in one database round trip. By querying
QA_Review__c, grouping by theCase__clookup, and selecting the relevant fields, you can efficiently get the data for the most recent review for each case. This result can then be used to populate aMapor a list of wrapper classes, avoiding loops with SOQL queries and ensuring the solution is scalable and performant. This minimizes Apex CPU time and avoids hitting the SOQL query limit. - 2
A developer needs to deploy a new Apex class and a new custom field on the Account object from a sandbox to production. They are using a change set. Which steps must be taken to ensure a successful deployment? (Select THREE)
Show answer details
Correct answer: A, B, D
For a successful deployment to production, all components (the Apex class and the custom field) must be in the change set. The Apex class must have an accompanying test class (which also must be in the change set) that provides at least 75% code coverage for the class being deployed. The overall code coverage in the production org must also be at least 75% after the deployment. Field-level security for profiles can be included in the change set and does not have to be configured manually.
- 3
The Model-View-Controller (MVC) architectural pattern is fundamental to the Lightning Platform. Which Salesforce feature correctly corresponds to the 'Model' component of the MVC pattern?
Show answer details
Correct answer: C
In the Salesforce MVC pattern, the 'Model' represents the data structure and database. This corresponds directly to the Standard and Custom Objects, along with their fields and relationships, which define the schema and how data is stored in the Salesforce database. The 'View' is the user interface (Visualforce, Lightning Components), and the 'Controller' is the business logic (Apex).
- 4
A developer needs to prevent recursive execution in an Opportunity trigger. The trigger updates a field on related Account records, which in turn causes the Account trigger to fire and update the original Opportunity, creating a loop. What is the standard, best-practice technique to prevent this recursion?
Show answer details
Correct answer: B
The standard and most efficient way to prevent trigger recursion within a single transaction is to use a static boolean variable. Static variables retain their value for the duration of the transaction. A common pattern is to have a helper class with a static boolean
hasRunvariable, initialized tofalse. The trigger checks this variable upon entry. If it'sfalse, it sets it totrueand executes the logic. If it'strue, it bypasses the logic, thus breaking the recursive loop. This is more performant than querying a custom setting. - 5
An architect is designing a data model for a recruiting application. There are three custom objects:
Position__c,Candidate__c, andApplication__c. A candidate can apply for multiple positions, and a position can have multiple candidates. TheApplication__cobject represents a single candidate's application for a specific position. If aPosition__crecord is deleted, all relatedApplication__crecords must also be deleted. However, deleting aCandidate__cshould not delete theirApplication__crecords; instead, it should prevent the deletion if applications exist.How should the relationships for the
Application__cobject be configured?graph TD Position -- "Master-Detail" --> Application Candidate -- "Lookup" --> ApplicationShow answer details
Correct answer: C
The correct data model is a Master-Detail relationship to
Position__cand a Lookup relationship toCandidate__c. The requirement for cascading deletion (deleting a Position deletes its Applications) directly points to a Master-Detail relationship, wherePosition__cis the master. The requirement that deleting aCandidate__cshould be prevented if applications exist (but not cascade delete them) points to a Lookup relationship. A standard lookup relationship with the "Don't allow deletion of the lookup record that's part of a lookup relationship" option selected will enforce this behavior. An object can have at most two master-detail relationships, but the behavior described for theCandidate__cobject perfectly matches a lookup. - 6
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?
Show answer details
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. - 7
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?Show answer details
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. - 8
A developer is writing a test class for an Apex trigger that fires on
after updateof Account records. The trigger makes a callout to an external service. The test method fails with anSystem.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?Show answer details
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. Theafter updatetrigger 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 useTest.startTest()andTest.stopTest()to ensure the DML is committed before the asynchronous logic executes. - 9
A university is building a student management application. They have custom objects for
Student__c,Course__c, andEnrollment__c. A student can enroll in many courses, and a course can have many students. TheEnrollment__cobject represents a student's enrollment in a specific course and contains details likeGrade__candSemester__c. When aStudent__crecord is deleted, all their relatedEnrollment__crecords must also be deleted. Which data model correctly represents this relationship?Show answer details
Correct answer: C
This scenario describes a many-to-many relationship between Student and Course, implemented with
Enrollment__cas 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__cmust have a Master-Detail relationship toStudent__c. The relationship toCourse__ccan 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 } - 10
A developer is tasked with creating a nightly batch job that processes all
Order__crecords marked as 'Pending Fulfillment'. The job must aggregate line items for each order, calculate a total shipping weight, and update aTotal_Weight__cfield on theOrder__crecord. The org contains millions ofOrder__crecords. Which Apex features are essential for building a scalable and efficient solution? (Select THREE)Show answer details
Correct answer: A, D, E
To process millions of records, Batch Apex (using the
Database.Batchableinterface) is the correct choice as it processes records in manageable chunks, respecting governor limits. To run the job nightly, the class must also implement theSchedulableinterface. Within thestartmethod of the batch class, aDatabase.QueryLocatormust be used to build the scope of records to process. AQueryLocatorcan handle up to 50 million records, making it essential for large data volumes.
