Skip to main content
← Back to Blog
2026-05-19 · 12 min readSalesforceTipsUpdated Oct 30, 2026

Salesforce Interview Preparation: Apex, LWC, Triggers & System Design

A revision guide for Salesforce developer interviews: Apex classes and sharing, bulkified collections, one-trigger-per-object handlers, SOQL and SOSL, LWC data and events, callouts with Named Credentials, platform events, governor limits and bulk tests. Code fixed and checked against the current Apex and LWC docs.

Avnish Yadav
AI Automation Engineer & Salesforce Developer
7 views
Salesforce Interview Preparation: Apex, LWC, Triggers & System Design

Salesforce interview preparation isn't only about syntax. It's about proving you can build reliable systems inside the platform's limits. This guide is for developers revising Apex, triggers, SOQL, LWC, integration and system design before an interview. I learned this the hard way when I bombed my first senior developer interview years ago. I could recite Apex syntax, but I froze when asked to design a trigger framework that stayed within governor limits.

This is part 1 of the Salesforce Interview Series. Part 2 covers Salesforce AI interview questions on Agentforce, Prompt Builder and Data 360, and part 3 answers common Apex, SOQL and LWC interview questions in more depth.

Key takeaways

  • Bulkify everything: query once into a Map, collect records in a List, and run one DML statement, never one per record.
  • Keep one trigger per object that delegates to a handler, and test it with 200 records.
  • For system design, match the tool to the job: Batch Apex for big nightly work, Queueable for callouts, platform events to decouple systems.

Why Salesforce interviews are different

Most developer interviews test algorithms and data structures. Salesforce interviews add platform rules, governor limits and architecture trade-offs. Your code runs in a shared multi-tenant environment, so expect questions like with sharing versus without sharing, which have no direct equivalent outside the platform.

Bulkification is writing Apex so that it handles a whole collection of records with a fixed number of SOQL queries and DML statements, instead of one query or update per record. Nearly every section below comes back to it.

1. Apex fundamentals that get you hired

Classes, interfaces and sharing

You'll be expected to write clean, testable Apex and to know when to use an abstract class versus an interface. A common whiteboard exercise is a notification service that sends email, SMS and in-app messages. A strong answer proposes an interface with one implementation per channel, not a long if-else block.

Interviewers also probe the sharing keywords. A class declared without sharing can access records that the current user otherwise can't. Salesforce recommends it only for classes that need system-level access (sharing keywords). The same page adds two points worth saying out loud: sharing keywords don't enforce object or field permissions, and a class without a declaration runs with sharing from API version 67.0. Applying without sharing to a whole service layer can expose records to users who shouldn't see them.

Collections: where bulkification starts

Maps, lists and sets are your everyday tools. A classic question: how do you get child records for many parents? The wrong answer queries inside a loop, which uses one SOQL query per record and hits the 100-query synchronous limit (governor limits).

// Don't: one query per account; 101 accounts throw a limit exception
for (Account a : [SELECT Id FROM Account LIMIT 101]) {
    List<Contact> contacts = [SELECT Id FROM Contact WHERE AccountId = :a.Id];
}

The right answer queries all children once and groups them in a Map<Id, List<Contact>>.

// Do: query all child records once, then group them by parent
List<Account> accounts = [SELECT Id FROM Account LIMIT 100];
Map<Id, List<Contact>> contactsByAccount = new Map<Id, List<Contact>>();

for (Contact c : [SELECT Id, AccountId FROM Contact WHERE AccountId IN :accounts]) {
    if (!contactsByAccount.containsKey(c.AccountId)) {
        contactsByAccount.put(c.AccountId, new List<Contact>());
    }
    contactsByAccount.get(c.AccountId).add(c);
}

Honestly, this tripped me up early in my career. I wrote a nested loop that queried inside a loop, and it worked on small data sets. Then I deployed it to production, and the batch job timed out. The docs tell you about limits, but they don't teach you to think in bulk from the start.

2. SOQL and SOSL

Expect questions on query optimization, relationship queries and common mistakes. LIMIT and OFFSET aren't a substitute for a selective WHERE clause. Know AggregateResult for rollups, and use a parent-to-child subquery to get child records in the same query.

A frequent question: how do you search text across several objects? Use SOSL with FIND and RETURNING, which returns typed results per object. Inside RETURNING, each object can have its own WHERE, ORDER BY, LIMIT and OFFSET, as long as you list at least one field (RETURNING FieldSpec). A single SOSL query returns at most 2,000 records.

3. Trigger patterns that survive production

One trigger per object

Almost every interviewer tests this. Keep one trigger per object and let it delegate to a handler class. If several triggers exist on the same object, Salesforce doesn't guarantee the order they run in, which makes bugs hard to trace (Triggers and Order of Execution).

Context variables and bulkification

The trigger reads Trigger.new, Trigger.old, Trigger.newMap and flags such as isAfter and isInsert (Trigger Context Variables). You can change field values through Trigger.new only in before triggers, so set them there and work on related records in after triggers. In a before insert trigger the record hasn't been created yet, so anything that needs its ID belongs in after insert (Context Variable Considerations).

// AccountTrigger.trigger
trigger AccountTrigger on Account (after insert, after update) {
    AccountTriggerHandler.handle();
}

// AccountTriggerHandler.cls
public with sharing class AccountTriggerHandler {
    public static void handle() {
        if (Trigger.isAfter && Trigger.isInsert) {
            ContactService.createDefaultContacts((List<Account>) Trigger.new);
        }
        if (Trigger.isAfter && Trigger.isUpdate) {
            AccountService.syncParentActivity(
                (Map<Id, Account>) Trigger.newMap,
                (Map<Id, Account>) Trigger.oldMap
            );
        }
    }
}

ContactService and AccountService are your own service classes (not shown). Outside the trigger body, Trigger.new is a List<SObject>, so cast it before passing it to a method that expects List<Account>.

Expect the question: "Why not put a SOQL query inside a for loop?" The answer isn't only "governor limits". Even under 100 queries, per-record queries make a transaction slow, and, as a rule of thumb, slow transactions hold record locks longer when users and jobs run at the same time.

4. LWC: frontend development on Salesforce

Lightning Web Components basics

Know the lifecycle, reactive fields, and public (@api) versus private properties. On @track: all fields are reactive when you assign a new value. You need @track only to observe changes made inside a plain object or array (Reactivity for Fields, Objects, and Arrays). Also know how to call Apex with @wire or imperatively.

For communication, use custom events from child to parent and Lightning Message Service across the DOM of a Lightning page, including between LWC, Aura and Visualforce (Lightning Message Service). Older code used a pubsub module for this; Lightning Message Service is the supported option for new work.

// accountList.js: call Apex imperatively
import { LightningElement } from 'lwc';
import getAccounts from '@salesforce/apex/AccountService.getAccounts';

export default class AccountList extends LightningElement {
    accounts;
    error;

    connectedCallback() {
        getAccounts()
            .then((result) => {
                this.accounts = result;
            })
            .catch((error) => {
                this.error = error;
            });
    }
}

The Apex method must be @AuraEnabled (Call Apex Methods Imperatively). Storing the error in a field, rather than only logging it, lets the template show it to the user. This component was tested with @salesforce/sfdx-lwc-jest@7.9.0, a minimal template and a mocked Apex method on 2026-10-30.

Rendering and performance

For large lists, mention lightning-datatable with infinite scrolling, which loads a subset of rows and fetches more as the user scrolls (lightning-datatable). Don't render thousands of rows in a for:each. Also be ready to compare lightning-record-form, lightning-record-edit-form and lightning-record-view-form with a custom UI built from scratch (Work with Records Using Base Components).

5. Integration patterns: connecting Salesforce to other systems

REST and SOAP APIs

Salesforce supports both. REST is simpler for modern apps, and SOAP still appears in older enterprise systems. You'll be asked how to make outbound callouts with HttpRequest and HttpResponse, and how to handle timeouts and retries.

// Outbound REST callout through a named credential
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Billing_API/invoices');
req.setMethod('GET');
req.setTimeout(20000); // milliseconds; the default is 10 seconds

HttpResponse res = new Http().send(req);
if (res.getStatusCode() == 200) {
    // parse and process
} else {
    // log the failure and decide whether to retry
}

Billing_API is a named credential you create in Setup. It holds the endpoint URL and points to an external credential with the authentication settings, so the Apex code never contains a secret (Named Credentials as Callout Endpoints). Callouts have their own limits: 100 per transaction, a timeout between 1 and 120,000 milliseconds, and no callout while DML or other pending work sits in the same transaction (Callout Limits and Limitations).

To show external data without copying it, mention Salesforce Connect, which reads and edits records in another system through external objects (Salesforce Connect). A rule of thumb: if the caller can wait, use platform events or a Queueable job; if it needs an answer now, use a REST callout with a sensible timeout.

6. System design for Salesforce roles

This is where senior candidates stand out. You'll get a scenario, for example a sales team that needs to sync data with an ERP, generate PDFs and send notifications. Your job is to design the flow and say where triggers, Queueable jobs, Batch Apex or platform events fit. Salesforce's Integration Patterns guide gives you the vocabulary.

Option What it does Trade-off When to use
Batch Apex Processes records in chunks, each with fresh limits Runs later, not in real time Nightly jobs over many records
Queueable Apex Runs one async job, can chain and make callouts One job at a time per chain Callouts after DML, follow-up work
Platform events Publishes messages that subscribers handle Eventual consistency, more moving parts Decoupling Salesforce from other systems
Bulk API Loads or extracts large data sets from outside External tooling and job monitoring Data coming from another system

Bulk data processing decisions

A typical question: "How would you process a nightly job that updates 500,000 records?" A good answer is Batch Apex with Database.Batchable, a sensible scope size and careful state handling. Each execute call is its own transaction with fresh limits, and a query locator can return up to 50 million records (Use Batch Apex). If the data comes from outside Salesforce, the Bulk API is often the better fit. Then explain how you'd log failures and retry them; interviewers listen for that.

Event-driven architecture

Platform events let systems publish and receive messages in real time (Platform Events Developer Guide). Instead of a batch job polling for changes, you publish an event when an account's status changes, and subscribers act on it. For an event-driven automation project I built, I used platform events to sync accounts to an external data warehouse, which kept the sync out of users' transactions.

7. Governor limits and performance pitfalls

You'll be drilled on limits. Per synchronous transaction, the current docs list 100 SOQL queries, 50,000 records retrieved by SOQL, 150 DML statements and 10,000 records processed by DML. Heap is 10 MB (25 MB asynchronous) and CPU time is 10,000 milliseconds, as listed on the page on 2026-10-30 (Winter '27 docs). Older guides often quote 6 MB and 12 MB, which is one more reason to check the page (Execution Governors and Limits). Limits change between releases, so quote the page rather than memory. The deeper question is how you stay under them.

A common mistake is DML inside a loop. Even under the limit, it's slow and, as a rule of thumb, holds locks longer. Collect the records, then update once:

// Don't: one update per record
for (Account a : accounts) {
    a.Rating = 'Hot';
    update a;
}

// Do: change the records, then one DML statement
for (Account a : accounts) {
    a.Rating = 'Hot';
}
update accounts;

8. Testing and deployment

Salesforce requires tests to cover at least 75% of your Apex code, and those tests must pass, before you deploy or package it (Testing and Code Coverage). Treat that as the floor. Interviewers ask how you write meaningful tests: bulk scenarios, negative paths and one focused test per behavior. You'll also discuss deployment: change sets, Salesforce DX with source control, and CI/CD pipelines.

@isTest
private class AccountTriggerTest {
    @isTest
    static void createsDefaultContactsInBulk() {
        List<Account> accounts = new List<Account>();
        for (Integer i = 0; i < 200; i++) {
            accounts.add(new Account(Name = 'Test ' + i));
        }

        Test.startTest();
        insert accounts;
        Test.stopTest();

        List<Contact> contacts = [SELECT Id FROM Contact WHERE AccountId IN :accounts];
        Assert.areEqual(200, contacts.size(), 'Each account should get one default contact');
    }
}

This test assumes ContactService.createDefaultContacts creates one contact per account. The Apex in this post was checked against the Apex Developer Guide and Apex Reference (Assert Class) but not deployed to an org.

Interviewers like to hear about a failure you've handled, such as a test that passed in one org and failed in another because it relied on existing data. Show that you know @TestSetup for shared test records (Using Test Setup Methods) and how to test with bulk data.

9. Common interview scenarios

"A trigger runs after insert, but it interferes with another process. How do you debug it?" Check the debug logs, trace the order of execution, and look for recursion. A static flag or a set of processed IDs stops a trigger from re-running on its own updates.

"A trigger must call an external system. How?" You can't make the callout in the trigger's transaction after DML, so enqueue a Queueable job that implements Database.AllowsCallouts, or publish a platform event (Queueable Apex).

These questions test whether you can map platform features to a business need under pressure. The best practice: write a trigger, then a test that inserts 200 records. Interviewers sometimes ask for exactly that live.

Frequently asked questions

What's the most common Salesforce interview question?

Governor limits: name one and explain how you stay under it. The SOQL limit of 100 queries per synchronous transaction comes up most. Explain how bulkified code and maps keep the query count fixed however many records arrive.

How do I prepare for an LWC-focused interview?

Build small components that call Apex, handle events and use reactive fields. Know the lifecycle hooks (constructor, connectedCallback, renderedCallback, disconnectedCallback) and when you'd use each. Learn Lightning Message Service for communication between components that aren't parent and child.

Do I need system design for a Salesforce developer interview?

Yes, especially for senior roles. Expect a scenario such as an integration with an external system and a question about how you'd build it. Know batch versus real-time patterns, event-driven designs and how to handle large data volumes.

What's the best way to practice triggers?

Write a trigger on Account or Opportunity that does more than a field update, such as creating child records or enqueueing a callout. Then write a test that inserts 200 records to prove it's bulk-safe. It's a common live exercise.

How can I stand out as a Salesforce candidate?

Show that you've built things that handle real data. Talk through one governor limit or integration failure you hit and how you fixed it, with the architecture and trade-offs. Reading Salesforce's integration patterns guide helps you speak to the practical concerns.

Before the interview

Revisit your own past mistakes. Pick a project where you hit a governor limit or a recursion bug, and walk through the fix out loud. A real story convinces more than a textbook answer. Also rehearse a few scenarios where you choose between Batch Apex and platform events, so you can explain the trade-offs instead of reciting them.

Then build a small proof of concept in a Developer Edition org: a trigger that processes 1,000 records, a Queueable callout with a retry, and an LWC that shows the result. It gives you concrete examples to talk about, and that's what interviewers remember.

Sources

Verified against the sources below on October 30, 2026. Products and docs change often: check the linked sources if something looks different.

  1. Apex Developer Guide: Execution Governors and Limits
  2. Apex Developer Guide (archived version 250.0): Execution Governors and Limits
  3. Apex Developer Guide: Use the with sharing, without sharing, and inherited sharing Keywords
  4. Apex Developer Guide: Triggers
  5. Apex Developer Guide: Trigger Context Variables
  6. Apex Developer Guide: Context Variable Considerations
  7. Apex Developer Guide: Common Bulk Trigger Idioms
  8. Apex Developer Guide: Triggers and Order of Execution
  9. SOQL and SOSL Reference: RETURNING FieldSpec
  10. LWC Developer Guide: Reactivity for Fields, Objects, and Arrays
  11. LWC Developer Guide: Call Apex Methods Imperatively
  12. LWC Developer Guide: Lightning Message Service
  13. LWC Developer Guide: Work with Records Using Base Components
  14. Lightning Component Reference: lightning-datatable
  15. Apex Developer Guide: Named Credentials as Callout Endpoints
  16. Apex Developer Guide: Callout Limits and Limitations
  17. Salesforce Help: Salesforce Connect
  18. Platform Events Developer Guide
  19. Apex Developer Guide: Use Batch Apex
  20. Apex Developer Guide: Queueable Apex
  21. Apex Developer Guide: Testing and Code Coverage
  22. Apex Developer Guide: Using Test Setup Methods
  23. Apex Reference Guide: Assert Class
  24. Salesforce Architects: Integration Patterns
All 3 parts in this series
Written by

Avnish Yadav

AI Automation Engineer & Salesforce Developer

Salesforce developer since June 2018. I build AI agents, n8n workflows and Salesforce integrations, and write up what holds up in real use.

About meLinkedIn

Share
Discussion

Comments

Loading comments...

Add a comment

Comments are reviewed before they appear.