Salesforce interview prep · Part 1 of 9

Top 30 Salesforce Interview Questions and Answers

The 30 Salesforce questions asked again and again - data model, security, Flow, Apex, LWC and integration - each answered in four steps with an example.

By Bhanu Pratap SinghLast reviewed 2026-10-2422 min read30 questions16 Beginner13 Intermediate1 Advanced
Level

These are the 30 questions that come up in almost every Salesforce interview, from admin to senior developer. Each one is answered with the same formula: what it is in one clear line, why it exists, a real example, and a summary to close the answer. Interviewers remember structure, not length.

Start here for the full picture, then use the "Go deeper" links to reach the part of the series that covers each topic in detail. One tip from real interviews: after the summary, add one line about your own work - "In my last project, I used this to..." - it turns theory into experience.

Q1BeginnerPlatform

What is multi-tenant architecture?

1What it is

Many companies (orgs) share one infrastructure, database and codebase. Each org's data is kept separate by its Org ID, so no org can see another's records.

2Why it matters

Sharing keeps costs low and lets Salesforce upgrade everyone at once, three times a year. Because the resources are shared, the platform has to stop any one org using too much - which is exactly why governor limits exist.

3Example

Shared Salesforce serversCompany ACompany BYour companyCompany DEach company gets a fair share. That share is the governor limit.

Think of one apartment building: every flat (org) has its own lock and its own things, but the water, electricity and lift are shared - and every flat has a meter. The meter is the governor limit.

4In short - say this in the interview

Shared infrastructure plus isolated data is multi-tenancy. It is why Salesforce upgrades everyone three times a year, and why governor limits exist.

Common mistake

Saying each customer gets its own server. They share one; only the data is separated.

Likely follow-ups
  • How does multi-tenancy affect the code you write?
  • What are the three releases called? (Spring, Summer and Winter.)
Q2BeginnerData model

What is the difference between standard and custom objects?

1What it is

Standard objects come built in - Account, Contact, Opportunity, Case. Custom objects are ones you create for your own data, and their API name ends in __c.

2Why it matters

Standard objects come with reports, apps, integrations and features already wired up, so you use them first. You build a custom object only when the data is truly unique to the business.

3Example

StandardCustom
AccountInvoice__c
ContactProject__c
OpportunityWarranty__c
CaseAsset_Log__c
Ready-made, with reports and appsBuilt for your business

4In short - say this in the interview

Standard objects come ready-made; custom objects, ending in __c, fill the gaps. Use standard first and go custom only for data that is unique to the business.

Common mistake

Building a custom "Customer__c" object when Account already does the job - and losing every feature built on Account.

Likely follow-ups
  • What suffix does a custom field have? (Also __c.)
  • What does __r mean? (A relationship name in SOQL.)
Q3BeginnerData model

What is the difference between a lookup and a master-detail relationship?

1What it is

Both link two objects. Master-detail is a tight parent-child bond: the child cannot exist without its parent. Lookup is a loose, usually optional link.

2Why it matters

The choice decides what happens on delete, who owns the child record, how it is shared, and whether you can use roll-up summary fields.

3Example

Lookup - a loose linkAccount (parent)Case (child)optionalown owner and sharing · parent optionalon delete: clear the field or block itMaster-detail - a tight linkInvoice (master)Invoice line (detail)requiredinherits sharing · deleting the master deletes itroll-up summary fields on the master
FeatureMaster-detailLookup
Parent requiredYesNo (optional by default)
Delete the parentChildren are deleted tooChildren stay; the field is cleared
Owner and sharingInherited from the parentThe child's own
Roll-up summary fieldsYesNo (not natively)
How many per objectUp to 2Up to 40 relationship fields in total

Order to Order_Line__c is master-detail: a line has no meaning without its order. Contact to Account is a lookup: a contact can exist on its own.

4In short - say this in the interview

Master-detail means the parent controls the child - required, deleted with it, shared like it, and roll-ups work. A lookup is an independent link.

Common mistake

Saying 40 lookups plus 2 master-details. The 40 counts all relationship fields on the object together.

Likely follow-ups
  • Can you convert a lookup to master-detail? (Yes, if every record has a value.)
  • How do you roll up over a lookup? (A Flow, Apex, or a tool such as DLRS.)
Q4BeginnerData model

What is a junction object?

1What it is

A custom object with two master-detail fields, one to each side, that creates a many-to-many relationship.

2Why it matters

Salesforce has no direct many-to-many field. A student takes many courses and a course has many students, so a record in the middle - the junction - holds each pairing.

3Example

Student - Enrollment__c - Course
Student  <-M-D-  Enrollment__c  -M-D->  Course

Riya         ->  enrolled in  ->  Apex, LWC
Apex course  ->  has          ->  Riya, Aman

The first master-detail field you create is the primary one. The junction record takes its look (icon and colour) and its owner from that primary master.

4In short - say this in the interview

Two master-detail fields on one object give you many-to-many: each junction record links one record on each side.

Common mistake

Using two lookups and expecting the same behaviour. You lose cascade delete, inherited sharing and roll-ups.

Likely follow-ups
  • What happens to the junction record when one master is deleted?
  • Can a junction object have roll-ups on both masters? (Yes.)
Q5IntermediateData modelConfiguration

What is the difference between Custom Metadata and Custom Settings?

1What it is

Both store configuration. Custom Metadata types (ending in __mdt) are metadata, so their records deploy with your code. Custom Settings records are data, so they do not.

2Why it matters

Both stop hardcoding values in Apex - you change the configuration without changing the code. Which one you choose depends on whether the value must travel between orgs, or differ per user.

3Example

Custom MetadataCustom Settings
Records deploy with codeYesNo - they are data
Different value per user or profileNoYes, with a Hierarchy setting
Best forApp configuration, mappingsPer-user switches and toggles
No hardcoded tax rate · Apex
Decimal gst = Tax_Rate__mdt.getInstance('GST').Rate__c; // 18

4In short - say this in the interview

Deployable configuration goes in Custom Metadata; values that change per user or profile go in a Hierarchy Custom Setting.

Common mistake

Storing per-environment secrets in either. Use Named Credentials for endpoints and keys.

Likely follow-ups
  • Does reading Custom Metadata count against SOQL limits? (getInstance does not.)
  • What is a List Custom Setting?
Q6BeginnerSecurity

What is the difference between a profile and a permission set?

1What it is

A profile gives a user their base access, and every user has exactly one. A permission set adds extra access, and a user can have as many as needed.

2Why it matters

The rule is least privilege: keep profiles minimal, then grant extra access with permission sets and permission set groups. Salesforce is moving permissions off profiles, so this is the modern answer.

3Example

LayerExampleGives
ProfileSales UserRead Account
+ Permission setDiscount ApproverEdit Discount__c
+ Permission set groupSales Ops bundleSeveral permission sets at once
= Effective accessRahulEverything above, added together

4In short - say this in the interview

The profile sets the floor and permission sets add on top. One profile per user, as many permission sets as needed.

Common mistake

Creating a new profile for every small difference. That is what permission sets are for.

Likely follow-ups
  • Can a permission set take access away? (No - but a muting permission set inside a group can.)
  • What is a permission set group?
Q7BeginnerSecurity

What is the role hierarchy?

1What it is

A tree of roles that opens record visibility upwards: a manager can see the records their team owns.

2Why it matters

It mirrors the reporting structure, so data access follows the org chart automatically, without a sharing rule for every manager.

3Example

Visibility flows up
CEO              sees everything below
  └ Sales Head   sees Rep A's and Rep B's records
      ├ Rep A    sees own records
      └ Rep B    sees own records

Rep A cannot see Rep B's records.

4In short - say this in the interview

The profile decides what you can do; the role decides which records you can see. Access rolls up the hierarchy to managers.

Common mistake

Thinking the role hierarchy controls object or field access. It only affects record visibility.

Likely follow-ups
  • Can you turn off "grant access using hierarchies"? (Only for custom objects.)
  • Is a role required for every user? (No.)
Q8IntermediateSecurity

What are org-wide defaults and sharing rules?

1What it is

Org-wide defaults (OWD) set the baseline access for each object - usually the most restrictive. The role hierarchy, sharing rules and manual sharing then open access up.

2Why it matters

Salesforce security works by starting locked and granting access, not the other way round. Set the OWD to the access the least-trusted user should have.

3Example

What can they do?objects, fields, system permissionsProfileexactly one per user - keep it minimalPermission sets and groupsmany per user - grant access hereObject: create, read, edit, deleteField-level security: see / edit a fieldWhich records?record-level sharingManual and team sharingSharing rulesRole hierarchyOrg-wide defaults (baseline)Each layer only adds access - never removes it.
  • 1. OWD: Private - the baseline.
  • 2. Role hierarchy - managers see their team's records.
  • 3. Sharing rules - by owner or by criteria.
  • 4. Manual sharing and teams - one record at a time.

Example: Opportunity OWD is Private, and a criteria-based sharing rule gives the North team Read access to every opportunity in the North region.

4In short - say this in the interview

The OWD locks records down; the role hierarchy, sharing rules and manual sharing only open them up.

Common mistake

Saying nothing can ever go below the OWD. Restriction rules can narrow access further on supported objects.

Likely follow-ups
  • What OWD options are there? (Private, Public Read Only, Public Read/Write, Controlled by Parent.)
  • What is the difference between owner-based and criteria-based sharing rules?
Q9IntermediateSecurityApex

What do with sharing, without sharing and inherited sharing mean?

1What it is

Class keywords that decide whether Apex respects the running user's record access.

2Why it matters

Apex runs in system mode by default. Without the right keyword, a controller behind an LWC can show a user records they are not allowed to see - a data leak.

3Example

The three keywords · Apex
public with sharing class AccountService {}    // respects the user's sharing
public without sharing class SystemJob {}      // sees every record (system mode)
public inherited sharing class Util {}         // follows whoever calls it

Sharing is record access only. For object and field security, add WITH USER_MODE to queries or use Security.stripInaccessible().

4In short - say this in the interview

Default to with sharing, use inherited sharing for shared utility classes, and use without sharing only on purpose. None of them checks field security.

Common mistake

Believing with sharing also hides fields the user cannot see. It does not.

Likely follow-ups
  • What happens if a class has no keyword?
  • What is the difference between USER_MODE and SYSTEM_MODE?
Q10BeginnerAutomationFlow

What are the types of Flow?

1What it is

Screen flows (with a user interface), record-triggered flows, schedule-triggered flows, autolaunched flows (called from Apex, a button or another flow) and platform event-triggered flows.

2Why it matters

Flow is now the main no-code automation tool: Salesforce retired Workflow Rules and Process Builder, ending support at the end of 2025.

3Example

A before-save record-triggered flow
Trigger    Opportunity is updated
   ↓
Condition  Stage = Closed Won
   ↓
Action     Closed_Won_Date__c = TODAY()

A before-save flow updates fields on the same record with no extra DML, so it is very fast. An after-save flow is for related records, emails and actions that need the saved record.

4In short - say this in the interview

Five types: screen, record-triggered, schedule-triggered, autolaunched and platform event-triggered. Use Flow first, and move to Apex when the logic gets complex or heavy.

Common mistake

Building new automation in Process Builder. It is retired - migrate it to Flow.

Likely follow-ups
  • When would you choose Apex over Flow?
  • What runs first, a before-save flow or a before trigger?
Q11BeginnerAutomationData quality

What is a validation rule?

1What it is

A formula that runs when a record is saved. If the formula returns TRUE, the save is blocked and the user sees an error.

2Why it matters

It enforces data quality at the source, for every way a record can be saved - the UI, imports and the API - without writing any code.

3Example

Closed Won needs an amount · Formula
AND(
  ISPICKVAL(StageName, "Closed Won"),
  ISBLANK(Amount)
)

The formula returns TRUE, so the record is not saved and the user sees: "Amount is required to close a deal."

4In short - say this in the interview

A validation rule is a formula on save: TRUE means an error is shown and the record is not saved.

Common mistake

Writing the formula for the valid case. It must describe the invalid case - TRUE blocks the save.

Likely follow-ups
  • Do validation rules run on delete? (No.)
  • Where do validation rules run in the order of execution?
Q12AdvancedAutomationTriggers

What is the order of execution?

1What it is

The fixed sequence of steps Salesforce follows every time a record is saved - from validation through triggers, flows and roll-ups to the final commit.

2Why it matters

It explains bugs like "why did my field get overwritten?" or "why did my trigger run twice?" - a favourite senior-level question.

3Example

1Load the record and new values2System validation (UI saves)3Before-save record-triggered flows4Before triggers5Validation rules6Duplicate rules7Save to database (not committed)8After triggers9Assignment and auto-response rules10Workflow updates (triggers run again)11After-save flows and processes12Roll-up summaries, sharing recalculation13Commit14After commit: emails, async ApexHighlighted: the steps you write code or flows in. Everything runs in one transaction until step 13.
StepWhat runs
1System validation
2Before-save record-triggered flows
3Before triggers
4Custom validation rules
5Duplicate rules
6Record saved (not yet committed)
7After triggers
8Assignment and auto-response rules
9After-save record-triggered flows
10Roll-up summaries and criteria-based sharing
11Commit to the database
12After commit: emails, async jobs

4In short - say this in the interview

Before-save flows, before triggers, validation, save, after triggers, after-save flows, roll-ups, then commit - with emails and async work after the commit.

Common mistake

Forgetting that a roll-up on the parent saves the parent too, which fires the parent's own triggers.

Likely follow-ups
  • Why can a trigger run twice in one save?
  • When are emails actually sent?
Q13BeginnerApexGovernor limits

What are governor limits?

1What it is

Per-transaction caps the platform enforces on queries, DML, CPU time and memory. Cross one and Salesforce stops the code and rolls back the transaction.

2Why it matters

Multi-tenancy: no single org is allowed to hog the shared servers. The limits also force code to handle real data volumes.

3Example

Limit (per transaction)SyncAsync
SOQL queries100200
Records retrieved by SOQL50,00050,000
DML statements150150
Heap size6 MB12 MB
CPU time10 s60 s
Callouts100100
Go deeperSalesforce Governor Limits, explained simplyEvery limit in plain words, wrong vs right code, diagrams and a SOQL simulator.

4In short - say this in the interview

Governor limits cap what one transaction can use - 100 SOQL, 150 DML, 10 seconds of CPU. Write bulk-safe code or hit a LimitException that cannot be caught.

Common mistake

Saying you can catch a limit exception. You cannot - you design to stay under the limits.

Likely follow-ups
  • How do you check usage at runtime? (The Limits class.)
  • Why are async limits higher?
Q14BeginnerApexBulkification

What is bulkification?

1What it is

Writing code that handles 200 records as efficiently as it handles one.

2Why it matters

Triggers receive records in batches of up to 200. SOQL or DML inside a loop runs once per record and breaks the limits fast.

3Example

Wrong: 200 contacts, 200 queries200 contactsDatabaseFails at query 101: Too many SOQL queriesRight: collect Ids, then 1 query200 contactsSet of Account IdsDatabasecollect1 query
Wrong: DML inside the loop
for (Account a : accs) {
    insert new Contact(LastName = a.Name, AccountId = a.Id);
}
Right: collect, then one DML
List<Contact> cons = new List<Contact>();
for (Account a : accs) {
    cons.add(new Contact(LastName = a.Name, AccountId = a.Id));
}
insert cons;

4In short - say this in the interview

No SOQL or DML inside loops: collect first, then act once. Always test with 200 records, not one.

Common mistake

Testing with a single record and calling the code done.

Likely follow-ups
  • Why is a Map<Id, sObject> useful here?
  • How many records does a trigger receive at once?
Q15BeginnerApexTriggers

What are trigger context variables?

1What it is

Built-in variables that tell a trigger what is happening: Trigger.new, Trigger.old, newMap, oldMap, and flags such as isInsert, isUpdate, isBefore, isAfter.

2Why it matters

They tell you which records changed, what the values were before, and which event you are handling - so one trigger can serve every event correctly.

3Example

Did the phone number change? · Apex
if (Trigger.isUpdate) {
    for (Account a : Trigger.new) {
        Account old = Trigger.oldMap.get(a.Id);
        if (a.Phone != old.Phone) {
            // phone number changed
        }
    }
}
VariableHoldsNot available in
Trigger.newValues after the changeDelete triggers
Trigger.oldValues before the changeInsert triggers
Trigger.newMapNew values by IdBefore insert (no Id yet)

4In short - say this in the interview

Trigger.new holds the values after the change, Trigger.old the values before it; the maps give the same records by Id, and the flags say which event fired.

Common mistake

Using Trigger.newMap in a before insert trigger. The records have no Id yet, so it is null.

Likely follow-ups
  • What does Trigger.operationType give you?
  • How do you compare old and new values in bulk?
Q16BeginnerApexTriggers

When do you use a before trigger and when an after trigger?

1What it is

A before trigger changes the same record before it is saved. An after trigger runs once the record is saved and has an Id.

2Why it matters

Field updates in a before trigger need no extra DML, so they are faster and cannot cause recursion. Work on other records, or anything that needs the Id, belongs in an after trigger.

3Example

Save clickedBefore triggerValidationSaved (has Id)After triggerCommitchange fields hereno DML neededId is knownwork on relatedOne save, in orderTrigger.new can be changed only in the before trigger; in the after trigger it is read-only.
Before insertAfter insert
Typical workacc.Rating = 'Hot'; - no DML neededinsert new Task(WhatId = acc.Id);
Record IdStill nullAvailable
Trigger.newEditableRead-only

4In short - say this in the interview

Same record, use before. Other records, or you need the Id, use after.

Common mistake

Running an update DML on the same record from an after trigger. Set the field in a before trigger instead.

Likely follow-ups
  • Why is Trigger.new read-only in an after trigger?
  • How do you stop recursion?
Q17IntermediateApexTriggers

What is the trigger handler pattern, and how do you stop recursion?

1What it is

One trigger per object that hands the work to a handler class, plus a static guard that remembers what has already been processed in this transaction.

2Why it matters

The logic stays testable and runs in a known order, and a trigger that updates records cannot fire itself in an endless loop.

3Example

AccountTrigger.trigger · Apex
trigger AccountTrigger on Account (before insert, after update) {
    AccountHandler.run();
}
AccountHandler.cls · Apex
public class AccountHandler {
    // Static: lives for the whole transaction, shared by every trigger call.
    static Set<Id> processed = new Set<Id>();

    public static void run() {
        switch on Trigger.operationType {
            when BEFORE_INSERT {
                setDefaults((List<Account>) Trigger.new); // no Ids yet - nothing to guard
            }
            when AFTER_UPDATE {
                List<Account> todo = new List<Account>();
                for (Account a : (List<Account>) Trigger.new) {
                    if (processed.add(a.Id)) todo.add(a); // add() is false if already seen
                }
                syncContacts(todo);
            }
        }
    }
    static void setDefaults(List<Account> accs) { /* ... */ }
    static void syncContacts(List<Account> accs) { /* ... */ }
}
Go deeperApex Trigger Scenario Interview QuestionsTrigger scenarios with full handler code, recursion guards and bulk-safe roll-ups.

4In short - say this in the interview

One trigger per object, all logic in a handler class, and a static Set of processed Ids to guard against recursion.

Common mistake

Guarding with a static Boolean. It skips every later batch of 200 in the same transaction, so records 201 onwards are never processed.

Likely follow-ups
  • Why does a before insert guard not work with Ids?
  • What frameworks exist for this? (For example fflib or a simple TriggerHandler base class.)
Q18BeginnerApexSOQL

What is the difference between SOQL and SOSL?

1What it is

SOQL queries one object and its related records with exact filters. SOSL searches text across many objects at once.

2Why it matters

Pick by situation: if you know the object and the field, use SOQL. If you are searching for a word everywhere, use SOSL.

3Example

SOQL - querySELECT Name FROM Account WHERE …Account (+ related)one object, exact filtersyou know where the data isSOSL - searchFIND 'acme' IN ALL FIELDS …AccountContactLeadmany objects, text searchyou know the word, not the place
One of each · Apex
// SOQL - one object, exact filter
List<Account> accs = [SELECT Name FROM Account WHERE Industry = 'IT'];

// SOSL - text search across objects
List<List<SObject>> found = [FIND 'Rahul' IN ALL FIELDS
                             RETURNING Contact(Name), Lead(Name)];
SOQLSOSL
ReturnsA list of recordsA list of lists, one per object
Per transaction100 queries (sync)20 searches
Go deeperSOQL and SOSL Interview Questions and AnswersRelationship queries, aggregates, security in queries and large data volumes.

4In short - say this in the interview

SOQL is a targeted query on one object; SOSL is a global text search across many.

Common mistake

Using SOQL with LIKE '%text%' across several objects when one SOSL search would do.

Likely follow-ups
  • How do you query child records from a parent?
  • What is the maximum number of rows SOSL returns? (2,000.)
Q19IntermediateApexAsync

What is the difference between @future and Queueable Apex?

1What it is

Both run Apex asynchronously, in the background. Queueable is the modern, more flexible version.

2Why it matters

Async Apex is needed for callouts from triggers, heavy processing, and the higher governor limits background work gets.

3Example

@futureQueueable
ParametersPrimitives onlyAny type, including sObjects
Job Id to monitorNoYes
Chain another jobNoYes
Callouts@future(callout=true)Implement Database.AllowsCallouts
Start a Queueable job · Apex
Id jobId = System.enqueueJob(new SyncJob(accounts));

4In short - say this in the interview

Prefer Queueable: it takes any parameter, returns a job Id and can chain. @future is the older, simpler option.

Common mistake

Passing sObjects to an @future method. It only accepts primitives - pass Ids and query again.

Likely follow-ups
  • Why can @future not take sObjects?
  • How do you test async Apex? (Test.stopTest runs it.)
Q20IntermediateApexAsync

What is Batch Apex?

1What it is

Apex that processes very large data sets in chunks, through three methods: start, execute and finish.

2Why it matters

Every chunk runs as its own transaction with fresh governor limits, so one job can work through up to 50 million records.

3Example

Batch Apex: 1,000,000 recordsChunk 1200 recordsfresh limitsChunk 2200 recordsfresh limits· · ·Chunk 5,000200 recordsfresh limitsEach chunk is its own transaction, so the limits reset every time.
MethodRunsDoes
start()OnceReturns a query locator for up to 50 million records
execute()Once per chunk (200 by default)Processes that chunk
finish()OnceSends an email, or chains the next job
Run it in chunks of 200 · Apex
Database.executeBatch(new CleanupBatch(), 200);
// 1,000,000 records / 200 = 5,000 chunks, each with fresh limits

4In short - say this in the interview

For huge data volumes use Batch Apex: start queries, execute runs once per chunk with fresh limits, finish wraps up.

Common mistake

Keeping state across chunks in a normal variable. Implement Database.Stateful to keep it.

Likely follow-ups
  • What is the maximum scope size? (2,000.)
  • How many batch jobs can run at once? (5 active, 100 more in the flex queue.)
Q21IntermediateApexAsync

What is Schedulable Apex?

1What it is

Apex that runs at a set time, scheduled with a cron expression.

2Why it matters

Nightly jobs, periodic syncs and clean-ups run on their own, without anyone clicking a button.

3Example

Every day at 2:00 AM · Apex
public class NightlyJob implements Schedulable {
    public void execute(SchedulableContext sc) {
        Database.executeBatch(new CleanupBatch());
    }
}

System.schedule('Nightly', '0 0 2 * * ?', new NightlyJob());
SecondsMinutesHoursDayMonthWeekday
002**?

4In short - say this in the interview

Schedulable Apex is a time-based trigger for code, set with a cron expression - often used to start a batch job.

Common mistake

Making callouts directly in the execute method. Start a Queueable or batch with callouts enabled instead.

Likely follow-ups
  • How many jobs can be scheduled at once? (100.)
  • What does the ? mean in a cron expression?
Q22BeginnerApexTesting

What are test classes and code coverage?

1What it is

Classes marked @isTest that check your code works. Production deployments need 75% code coverage across the org, with all tests passing.

2Why it matters

They stop broken code reaching production. Every trigger must have some coverage too, or it cannot be deployed.

3Example

AccountTriggerTest.cls · Apex
@isTest
private class AccountTriggerTest {
    @isTest
    static void setsRatingHot() {
        Test.startTest();
        insert new Account(Name = 'Acme');
        Test.stopTest();

        Account a = [SELECT Rating FROM Account LIMIT 1];
        Assert.areEqual('Hot', a.Rating);
    }
}
  • Own test data - tests cannot see org data by default.
  • startTest / stopTest - fresh limits, and async work runs.
  • Always assert - coverage without assertions proves nothing.

4In short - say this in the interview

Create your own test data, wrap the call in startTest and stopTest, and always assert. 75% coverage is the minimum, not the goal.

Common mistake

Writing tests with no assertions just to reach 75%.

Likely follow-ups
  • Why avoid SeeAllData=true?
  • How do you test a callout? (HttpCalloutMock.)
Q23IntermediateLWC

What are the LWC lifecycle hooks?

1What it is

Methods LWC calls at each stage of a component's life, from creation to removal.

2Why it matters

They tell you where to load data and where it is safe to touch the DOM.

3Example

constructor()connectedCallback()renderrenderedCallback()no DOM yetload data herecan run many timesdisconnectedCallback()errorCallback()removed: clean upin a parent: a child threw
HookWhenUse it to
constructor()CreatedSet initial state - no DOM yet
connectedCallback()Inserted into the pageLoad data, subscribe
render()Before drawingPick a template (rarely needed)
renderedCallback()After every renderTouch the DOM - guard against loops
disconnectedCallback()RemovedClean up listeners and subscriptions
errorCallback()A child throwsShow a fallback

4In short - say this in the interview

Connected means inserted, rendered means painted, disconnected means removed - load data in connectedCallback, touch the DOM in renderedCallback.

Common mistake

Setting a tracked property in renderedCallback without a guard. It re-renders, calls itself again, and loops.

Likely follow-ups
  • In what order do parent and child hooks run?
  • Why can you not access child elements in the constructor?
Q24IntermediateLWC

What do @api, @track and @wire do?

1What it is

@api makes a property public, so a parent can set it. @track watches changes inside an object or array. @wire fetches data reactively.

2Why it matters

Together they control a component's inputs and when it re-renders.

3Example

parent.html · HTML
<c-child record-id={recId}></c-child>
child.js · JavaScript
@api recordId;                     // set by the parent
@track filters = { city: '' };      // watch changes inside the object

@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
record;                             // fetched again when recordId changes

Since Spring '20 every field is reactive when it is reassigned. @track is only needed to notice changes inside an object or array.

4In short - say this in the interview

@api exposes a property, @track watches inside objects and arrays, @wire fetches data and re-runs when its parameters change.

Common mistake

Adding @track to every field. Plain fields are already reactive.

Likely follow-ups
  • Can a child change an @api property? (No - it belongs to the parent.)
  • What does the $ in '$recordId' mean?
Q25IntermediateLWC

How do LWC components communicate?

1What it is

Parent to child with an @api property. Child to parent with a CustomEvent. Unrelated components with Lightning Message Service (LMS).

2Why it matters

It is one of the most common questions in LWC coding rounds, because every real page has components talking to each other.

3Example

Parent componentChild component@apipropertyCustomEventdispatchEventAny other componentMessage channelLightning Message ServicepublishsubscribeDown with @api, up with events, sideways with Lightning Message Service.
The child tells its parent · JavaScript
this.dispatchEvent(new CustomEvent('select', { detail: id }));

4In short - say this in the interview

Down with properties, up with events, sideways with LMS.

Common mistake

Using LMS between a parent and its own child. Properties and events are simpler and clearer.

Likely follow-ups
  • What do bubbles and composed do on an event?
  • How does the parent listen? (onselect={handleSelect}.)
Q26IntermediateLWCApex

When do you use @wire and when an imperative Apex call?

1What it is

@wire calls Apex automatically and reactively. An imperative call runs when you call it, and returns a Promise.

2Why it matters

Button clicks and anything that changes data (DML) need an imperative call. Read-only data for display suits @wire, with the Apex method marked cacheable=true.

3Example

Both ways · JavaScript
// Wire: automatic and cached
@wire(getAccounts) accounts;

// Imperative: on a click
handleClick() {
    getAccounts()
        .then((r) => { this.data = r; })
        .catch((e) => { this.error = e; });
}

4In short - say this in the interview

Read-only and reactive, use @wire. On demand, or anything with DML, use an imperative call.

Common mistake

Wiring a method that does DML. A cacheable method cannot change data.

Likely follow-ups
  • How do you refresh wired data? (refreshApex.)
  • Why must a wired Apex method be cacheable?
Q27BeginnerLWC

What is Lightning Data Service?

1What it is

Built-in create, read, update and delete for single records with no Apex: record forms, getRecord, updateRecord and related adapters.

2Why it matters

It shares one cache across components, enforces field security and sharing automatically, and needs no Apex - so no test class either.

3Example

View, edit and save - zero Apex · HTML
<lightning-record-form
    object-api-name="Account"
    record-id={recordId}
    layout-type="Full"
    mode="edit">
</lightning-record-form>

4In short - say this in the interview

For single-record work, reach for Lightning Data Service before Apex.

Common mistake

Writing an Apex controller just to read one record's fields.

Likely follow-ups
  • When do you still need Apex? (Many records, complex queries, or DML across objects.)
  • What is the difference between record-form, record-edit-form and record-view-form?
Q28IntermediateIntegration

What are Platform Events?

1What it is

Publish-subscribe messages, defined like an object with the suffix __e. Publishers send events to an event bus, and any number of subscribers receive them.

2Why it matters

They decouple systems: the publisher never waits for, or even knows about, the subscribers. They power real-time notifications inside and outside Salesforce.

3Example

PublishersApex EventBus.publishFlowExternal system (API)Event buskept for 72 hoursSubscribersApex trigger (after insert)FlowExternal (Pub/Sub API)The publisher does not know who listens - add a subscriber without touching it.
Publish one event · Apex
EventBus.publish(new Order_Event__e(Order_Id__c = orderId));

Publishers: Apex, Flow or an external API. Subscribers: an Apex trigger, a Flow, an LWC (empApi) or an external app through the Pub/Sub API.

Go deeperSalesforce Integration Interview QuestionsPlatform Events vs Change Data Capture, APIs, OAuth and callouts in depth.

4In short - say this in the interview

A fire-and-forget event bus: publishers send, subscribers react, and neither waits for the other.

Common mistake

Expecting an event to roll back with the transaction. "Publish immediately" events are sent even if the transaction fails - choose "after commit" when that matters.

Likely follow-ups
  • How long are events kept for replay? (72 hours.)
  • What is the difference between Platform Events and Change Data Capture?
Q29IntermediateIntegration

How do you make a REST callout, and what is a Named Credential?

1What it is

Apex calls an external API with HttpRequest. A Named Credential stores the endpoint and the authentication, so the code only names it.

2Why it matters

No URLs or secrets are hardcoded in the code, OAuth tokens are handled for you, and each environment can point to its own endpoint.

3Example

Salesforceyour orgCalls inReaches outREST APISOAP APIBulk API 2.0Composite / Pub/Sub APICallouts + Named CredentialsPlatform EventsChange Data CaptureOutbound MessagesPick by direction first, then by volume and timing - real time, near real time, or bulk.
callout: means a Named Credential · Apex
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Payment_API/orders');
req.setMethod('POST');
req.setBody(JSON.serialize(order));
HttpResponse res = new Http().send(req);

A callout after uncommitted DML in the same transaction fails with "You have uncommitted work pending". Make the callout first, or move it to a Queueable. Test callouts with HttpCalloutMock.

4In short - say this in the interview

Callouts go through Named Credentials so no secret lives in code, and they run asynchronously when DML comes first.

Common mistake

Putting an API key in a Custom Setting or in the code.

Likely follow-ups
  • What is an External Credential?
  • Why can a trigger not make a callout directly?
Q30BeginnerDevOps

What are sandboxes, and how do you deploy?

1What it is

Sandboxes are copies of production for building and testing. Changes move between orgs with change sets, the Salesforce CLI or DevOps Center.

2Why it matters

You never build directly in production. Each change is built, tested and approved before it reaches real users.

3Example

Dev sandbox → Git → UAT → Production · Terminal
sf project deploy start --target-org uat
SandboxCopiesRefresh every
DeveloperMetadata only1 day
Developer ProMetadata, more storage1 day
Partial CopyMetadata and a sample of data5 days
FullEverything29 days
Go deeperSalesforce Cheat Sheet: Limits and Key FactsThe numbers and facts to revise the night before, including testing and deployment rules.

4In short - say this in the interview

Build in a sandbox, keep the source in Git, and deploy with the Salesforce CLI or DevOps Center.

Common mistake

Testing a data migration in a Developer sandbox, which has no production data.

Likely follow-ups
  • What is the difference between a change set and source-driven deployment?
  • What is a scratch org?

Answers describe documented behaviour, checked against the sources listed. Platforms change between releases - confirm limits and versions before an interview.