ApexSensei

All practice exams

Salesforce PD1 practice exam

Twelve original sample questions for Platform Developer I, with answers and short explanations. Sign in to take the full 96-question practice exam, then write the matching Apex on graded drills.

Salesforce Certified Platform Developer · 96 in-app questions · official pass mark 68%

Take the full 96-question practice exam

Sample questions

These samples are original ApexSensei items. They are not official Salesforce exam questions and they are not copied from the signed-in question bank.

1. Cedar Labs needs a count of Lab_Sample__c children on Lab_Batch__c. The relationship is a lookup, so a native roll-up summary is unavailable. What is the usual programmatic approach?

Developer Fundamentals

  • A trigger or Queueable that updates a number field on the parent after child changes
  • A formula field on the parent that calls COUNT()
  • Turning the lookup into a junction object only
  • A roll-up summary defined on the child

Answer. A trigger or Queueable that updates a number field on the parent after child changes

Native roll-ups need master-detail. Formulas cannot count children. Apex (or a flow) maintains a number field when samples are inserted, updated, or deleted.

2. A developer wants an assistant inside VS Code to draft a test class from a selected Apex method. Which product is that, and what must they still do?

Developer Fundamentals

  • Agentforce for Developers can draft the test; the developer must review, compile, and run it
  • A Service agent writes production tests in the org by itself
  • Prompt Builder deploys tests on every save
  • Einstein Bots replace unit tests

Answer. Agentforce for Developers can draft the test; the developer must review, compile, and run it

Agentforce for Developers is the coding assistant in VS Code and Code Builder. It does not skip compilation, coverage, or your review. Service agents and bots are not the test runner.

3. Why keep Lightning web components focused on presentation and put DML in Apex service classes?

Developer Fundamentals

  • MVC-style separation keeps UI reusable and makes sharing and field-level security easier to reason about
  • DML from the browser avoids governor limits
  • Service classes skip the save order of execution
  • UI markup cannot display queried records

Answer. MVC-style separation keeps UI reusable and makes sharing and field-level security easier to reason about

The Lightning component framework expects the client to render and the server to enforce data rules. DML in the browser is not a supported way around governors, and service classes still participate in the save order.

4. InvoiceService is declared without sharing. A Visualforce controller declared with sharing calls it. Which sharing context do queries inside InvoiceService use?

Process Automation and Logic

  • System sharing context, because the service class declared without sharing
  • The Visualforce controller's with sharing, because sharing is always inherited
  • Organization-wide defaults only, ignoring sharing keywords
  • The running user's sharing, always, regardless of the keyword

Answer. System sharing context, because the service class declared without sharing

A called class that declares without sharing does not inherit the caller's with sharing. Use inherited sharing when the callee should follow the caller.

5. A before-insert Account trigger queries Contacts for each Account in Trigger.new with a SOQL statement inside the for-loop. What fails first on a 200-row insert?

Process Automation and Logic

  • The per-transaction SOQL query limit
  • View state
  • The DML row limit
  • The heap size limit, always before SOQL

Answer. The per-transaction SOQL query limit

One query per row in a 200-row trigger exceeds the 100-SOQL synchronous limit. Query once, collect Ids, and use a map. Heap or DML is not what this loop burns first.

6. An after-insert Case trigger inserts a Task. A record-triggered flow then updates the Case, so the trigger runs again and inserts a second Task. What should the developer add?

Process Automation and Logic

  • A static recursion guard, or a flow entry condition, so the Task work runs once
  • Test.seeAllData on the trigger
  • Database.emptyRecycleBin in the trigger
  • A SOSL query in the constructor

Answer. A static recursion guard, or a flow entry condition, so the Task work runs once

A later update on the same record re-enters after-insert/after-update work. Guard the Task insert, or stop the flow from writing a no-op update.

7. A trigger must call an external REST API after the Account save succeeds. Which shape is supported?

Process Automation and Logic

  • Enqueue a Queueable that implements Database.AllowsCallouts, or call @future(callout=true), after the DML
  • Http.send inside the after-insert trigger in the same transaction
  • A callout in before insert, before any DML
  • Database.getQueryLocator inside the trigger

Answer. Enqueue a Queueable that implements Database.AllowsCallouts, or call @future(callout=true), after the DML

You cannot make a callout after DML in the same transaction. Async Apex that allows callouts runs after the save commits. QueryLocator is for batch start methods.

8. A Lightning record page should list related Orders whenever accountId is set, and refresh if that Id changes. The Apex method only reads data. Which call style?

User Interface

  • @wire to a cacheable Apex method
  • An imperative call in connectedCallback only, ignoring later Id changes
  • window.fetch to /services/data without a session
  • A Visualforce remoting adapter imported into the LWC

Answer. @wire to a cacheable Apex method

@wire is reactive: it re-requests when accountId changes and can use the cache for read-only Apex. A one-shot connectedCallback call goes stale. Browser fetch without a session is not how LWC talks to your org.

9. An LWC table must hide Opportunity.Amount when the running user's field-level security hides that field. The Apex class is without sharing and the SOQL selects Amount. What should the developer do?

User Interface

  • Strip inaccessible fields with Security.stripInaccessible or query in USER_MODE before returning rows
  • Rely on with sharing alone
  • Hide the column with CSS only
  • Convert Amount to a formula field

Answer. Strip inaccessible fields with Security.stripInaccessible or query in USER_MODE before returning rows

with sharing enforces record sharing, not field-level security. Apex that queries in system mode must strip or use user mode so hidden fields never reach the client.

10. A service class makes an HTTP callout. The test must not hit the network and must assert the parsed status code. What does the test register?

Testing, Debugging, and Deployment

  • A class that implements HttpCalloutMock, set with Test.setMock
  • SeeAllData=true so the test can call production
  • Test.loadData of Account records
  • Schema.describeSObjects in @TestSetup

Answer. A class that implements HttpCalloutMock, set with Test.setMock

Callout tests inject a mock response. SeeAllData does not stub HTTP. Loading Accounts or describing schema does not stand in for the callout.

11. A test inserts 200 records and then enqueues a Queueable. Assertions must see the job's DML. How should the test be structured?

Testing, Debugging, and Deployment

  • Enqueue inside Test.startTest() and Test.stopTest(); assert after stopTest
  • Assert immediately after enqueue, before startTest
  • Call System.abortJob from @TestSetup
  • Run Database.executeBatch from a Visualforce getter

Answer. Enqueue inside Test.startTest() and Test.stopTest(); assert after stopTest

stopTest runs queued asynchronous work and gives that work a fresh set of governor limits. Asserting before that point reads the database too early.

12. CI should run a check-only deploy of the same project package that production will receive, using the current sf CLI. Which command family?

Testing, Debugging, and Deployment

  • sf project deploy start --dry-run (validate)
  • sf org assign permset
  • A retrieve-only metadata pull
  • Uploading a change set by hand with no validation

Answer. sf project deploy start --dry-run (validate)

A dry-run / validate deploy compiles and runs tests without committing to the target org. Assigning a permission set or retrieving metadata does not validate the package you are about to ship.

Hands-on Apex drills

A practice exam tests recall. Drills make you write Apex in your own Developer org. Related modules: Apex basics · Classes & objects · Unit testing · Triggers.

Take the full 96-question practice exam