10 free Salesforce Platform Developer practice questions with the correct answer and a full explanation for each, taken from the CertStash pack of 439 questions. Work through them, then open each answer to check your reasoning.
Get all 439 questions (US$39) · Download these 10 as a PDF
Question 1
Which statement results in an Apex compiler error?
Show answer and explanation
Correct answer: D. List<string> s = List<string>{'a','b','c');
A list literal has to be constructed with the new keyword and closed with the same kind of bracket it opened with. Option D writes List<string> s = List<string>{'a','b','c'); which omits new and closes a brace with a parenthesis, so the compiler rejects it before the code ever runs. The other three lines are legal Apex: multiple variables of one type can be declared and initialised in a single statement, and a declared variable may be left unassigned.
Why the other options are wrong
- A. This compiles. Leas is read as an unresolved type name only if no such type exists, and the exam prints this line as Map<Id, Lead>, so the statement is a valid map construction from a SOQL result.
- B. Declaring two Date variables in one statement and initialising them with Date.today() and Date.valueOf() is valid Apex.
- C. Apex allows several variables of the same type in one declaration, and leaving c uninitialised is legal because it simply defaults to null.
Question 2
A method is passed a list of generic sObjects as a parameter.
What should the developer do to determine which object type (Account, Lead, or Contact, for example) to cast each sObject?
Show answer and explanation

Question 3
What should a developer use to implement an automatic Approval Process submission for Cases?
Show answer and explanation
Correct answer: C. Process Builder
Process Builder can submit a record for approval as one of its actions, so a Case can be entered into an Approval Process automatically when the process criteria are met. That makes it the declarative tool built for this exact requirement.
Why the other options are wrong
- A. Assignment Rules route a Case to a user or queue. They have no approval submission action.
- B. Scheduled Apex is code, and the requirement is served by a declarative feature. It also runs on a schedule rather than on the record event.
- D. A Workflow Rule cannot submit a record for approval. Its actions are limited to field updates, email alerts, tasks and outbound messages.
Question 4
When viewing a Quote, the sales representative wants to easily see how many discounted items are included in the Quote Line Items.
What should a developer do to meet this requirement?
Show answer and explanation
Correct answer: C. Create a roll-up summary field on the Quote object that performs a SUM on the quote Line Item Quantity field, filtered for only discounted Quote Line Items.
that performs a SUM on the quote Line Item Quantity field, filtered for only discounted Quote Line Items. Quote Line Item is the detail side of a master-detail relationship to Quote, which is exactly the condition a roll-up summary field requires. The roll-up can aggregate the Quantity field and apply a filter so only discounted line items are counted, and the total is maintained by the platform on the parent Quote with no code. That gives the sales representative the figure directly on the Quote record.
Why the other options are wrong
- A. A trigger is code where a declarative roll-up already does the job, and querying the field does not by itself surface the number on the Quote.
- B. A Workflow Rule field update cannot aggregate values from many child records into a parent total.
- D. Formula fields evaluate on a single record and cannot sum values across child records. Cross-object formulas only reach upward to a parent.
Question 5
A Developer wants to get access to the standard price book in the org while writing a test class that covers an OpportunityLineItem trigger.
Which method allows access to the price book?
Show answer and explanation
Correct answer: A. Use Test.getStandardPricebookId() to get the standard price book ID.
standard price book ID. Test.getStandardPricebookId() returns the ID of the org's standard price book from inside a test, which is the supported way to get at it when the test cannot see organisation data. A new PricebookEntry can then be created against that ID so an OpportunityLineItem can be inserted and the trigger exercised.
Why the other options are wrong
- B. SeeAllData=true couples the test to org data, and deleting the standard price book is destructive and not permitted.
- C. Test.loadData() loads records from a static resource. The standard price book already exists and cannot be created this way.
- D. @TestVisible exposes private members of Apex classes to tests. It has nothing to do with record visibility.
Question 6
Where can a developer identify the time taken by each process in a transaction using Developer Console log inspector?
Show answer and explanation
Correct answer: C. Timeline tab under Execution Overview panel
The Timeline tab in the Execution Overview panel plots the transaction against elapsed time and shows how long each category of work took, so it is where a developer sees the time consumed by each process. The other panels describe what ran and in what order rather than how long it took.
Why the other options are wrong
- A. There is no Performance Tree tab. The Stack Tree panel holds Execution Tree and Performance Tree views of call nesting, not per-process timing.
- B. The Execution Tree shows the hierarchy of what executed, not the duration of each step.
- D. Save Order shows the order of save operations for the transaction, not timing.
Question 7
A developer working on a time management application wants to make total hours for each timecard available to application users. A timecard entry has a Master-
Detail relationship to a timecard.
Which approach should the developer use to accomplish this declaratively?
Show answer and explanation
Correct answer: B. A Roll-Up Summary field on the Timecard Object that calculates the total hours from timecard entries for that timecard
calculates the total hours from timecard entries for that timecard Timecard Entry is the detail side of a master-detail relationship to Timecard, so a roll-up summary field on Timecard can SUM the hours from its entries. The platform maintains the total automatically and it is available to users on the Timecard record, which satisfies the requirement declaratively with no code.
Why the other options are wrong
- A. A Visualforce page is code, so it fails the declarative requirement.
- C. A Process Builder field update would have to recalculate the running total itself and would miss updates and deletes that a roll-up handles natively.
- D. An Apex trigger is code, which the question rules out.
Question 8
Which approach should be used to provide test data for a test class?
Show answer and explanation
Correct answer: C. Use a test data factory class to create test data.
A test data factory is a dedicated class that builds the records tests need, so setup logic is written once and reused across the whole test suite. Tests stay isolated from org data, remain valid when required fields change because only the factory has to be updated, and each test still runs against data it created itself.
Why the other options are wrong
- A. Querying existing records makes tests depend on org data, which is unavailable by default and differs between orgs, so tests become fragile.
- B. Anonymous blocks are run manually and are not part of the test run, so they cannot supply data to a test method.
- D. @TestVisible only widens access to private members. It does not create records.
Question 9
Which approach should a developer take to automatically add a `Maintenance Plan` to each Opportunity that includes an `Annual Subscription` when an opportunity is closed?
Show answer and explanation
Correct answer: D. Build an Opportunity trigger that adds an OpportunityLineItem record.
OpportunityLineItem record. The requirement fires when the Opportunity is closed, so the trigger belongs on Opportunity where that field change is visible. What has to be added is a product line on the Opportunity, and product lines are OpportunityLineItem records. So the answer is an Opportunity trigger that inserts an OpportunityLineItem.
Why the other options are wrong
- A. The event is the Opportunity closing, which an OpportunityLineItem trigger does not see, and a PricebookEntry is a price list entry rather than a line on the deal.
- B. The trigger is on the wrong object: closing the Opportunity does not fire an OpportunityLineItem trigger.
- C. A PricebookEntry adds a product to a price book. It does not add anything to the Opportunity.
Question 10
What is the requirement for a class to be used as a custom Visualforce controller?
Show answer and explanation
Correct answer: C. Any top-level Apex class that has a default, no-argument constructor
argument constructor When a page names a custom controller, the platform has to instantiate that class with no arguments, so the class must be a top-level Apex class with a default no-argument constructor. Nothing else is required: no interface, no particular return type.
Why the other options are wrong
- A. A constructor cannot return a PageReference. Constructors return nothing, and action methods are what return PageReference.
- B. PageReference is not extendable, and a controller does not derive from it.
- D. There is no controller interface to implement. Standard controller extensions take a StandardController argument, but that is a different scenario.
That was 10 of 439.
The full Salesforce Platform Developer pack has all 439 questions, each with the answer, the explanation and why the other options are wrong, plus a questions-only copy for timed runs. US$39, paid once, with free monthly updates and a pass-or-your-money-back guarantee.
