Technical interviews for Salesforce developers evaluate not just your syntax knowledge, but how well you understand governor limits, asynchronous design patterns, and modern UI architectures. Here is a curated guide to 15 essential Salesforce interview questions with clear explanations and best-practice examples.
1. Asynchronous Apex & Batch Processing
Q1: What are the batch size boundaries in Batch Apex?
When invoking Database.executeBatch(instance, scopeSize), the batch execution boundaries are:
- Default Batch Size: 200 records.
- Minimum Batch Size: 1 record.
- Maximum Batch Size: 2,000 records.
execute() method makes external callouts or executes heavy transactional calculations that risk hitting governor limits (such as SOQL query limits or CPU timeout limits), tune your scope down from 200 to 50 or even 1.
Q2: Can you call a @future method from inside a Batch Apex class?
No. Calling an asynchronous @future method from another asynchronous execution context (like a Batch class execute() method) throws a runtime exception (System.AsyncException: Future method cannot be called from a future or batch method).
finish() method instead of using @future inside the execute() loop.
Q3: What is Queueable Apex, and when should you choose it over Future methods?
Queueable Apex is an asynchronous framework implemented by creating a class with the Queueable interface. It provides distinct advantages over @future methods:
- Complex Types: Accepts sObjects and custom Apex objects as parameters (not just primitive types).
- Job Monitoring:
System.enqueueJob()returns anAsyncApexJobID for status tracking. - Chaining: A Queueable job can start another Queueable job from its
execute()method.
Q4: What is Batch Apex, and what are its key platform limits?
Batch Apex processes large datasets up to 50 million records asynchronously in chunks. Key architectural constraints include:
- Up to 5 concurrent batch jobs can run simultaneously in an org.
- Up to 100 batch jobs can be held in the Apex flex queue in
Holdingstatus. - Use
Database.Statefulin the class signature to preserve instance variable state across chunk executions.
2. Integration & Data Synchronization
Q5: How do you synchronize updates from an external server back into Salesforce?
Mark a custom field as an External ID on the target Salesforce object. The external system can then perform an UPSERT REST/SOAP API operation using this External ID as the unique key. If a record with that external identifier exists, Salesforce updates it; if not, a new record is created automatically without duplicate SOQL queries.
Q6: What is the difference between Database.insert and standard insert?
insert records;(DML Statement): Executes an all-or-none transaction. If any single record fails validation, the entire transaction rolls back.Database.insert(records, false);(Database Method): Supports partial processing. Setting the second parameter (allOrNone) tofalseallows valid records to save while logging failed records in aDatabase.SaveResult[]array.
3. Lightning Frameworks (Aura & LWC)
Q7: How do you handle page navigation in Lightning?
- Lightning Web Components (LWC): Use the
lightning/navigationservice with theNavigationMixinwrapper to navigate to record pages, list views, or external URLs. - Aura: Use the
lightning:navigationcomponent service alongsidepageReferenceUtils.
Q8: How do you display dynamic modal dialogs in Lightning?
- In Modern LWC: Extend
LightningModalto create clean, promise-based modal containers that pass return values back to the invoking component upon closing. - In Legacy Aura: Use the
lightning:overlayLibraryservice tag to programmatically render dynamic modals and popovers.
Q9: Which interface makes an Aura or LWC component available as a Quick Action?
- Aura: Implement
force:lightningQuickAction(standard modal) orforce:lightningQuickActionWithoutHeader(custom modal framing). - LWC: Configure your component's XML metadata (
.js-meta.xml) with targetlightning__RecordActionand setactionTypetoScreenActionorAction.
Q10: How do parent and child components communicate in Lightning?
- Parent-to-Child (LWC): The parent passes data to public properties decorated with
@api, or calls public@apimethods defined on the child component. - Parent-to-Child (Aura): Use the
<aura:method>tag declared in the child component. - Child-to-Parent: The child dispatches a standard DOM
CustomEvent, which the parent listens for declaratively or via an event listener.
Q11: What are the primary event types in the Aura framework?
- Component Events: Fired by a child component and handled either by the component itself or by a parent component within its direct containment hierarchy.
- Application Events: Broadcast across the entire application using a publish-subscribe model, handled by any component listening for the event regardless of parentage.
4. Advanced Apex & Trigger Architecture
Q12: What is the difference between Trigger.new and Trigger.newMap?
Trigger.new: Returns a list (List<sObject>) of the new versions of the sObject records. Available inINSERT,UPDATE, andUNDELETEtriggers.Trigger.newMap: Returns a map of IDs to the new versions of the sObject records (Map<Id, sObject>). Available only inAFTER INSERT,BEFORE UPDATE,AFTER UPDATE, andAFTER UNDELETEtriggers (records must have an ID).
Q13: What does the with sharing keyword do in Apex?
The with sharing keyword enforces the sharing rules of the current running user (organization-wide defaults, role hierarchies, and sharing rules). It does not enforce object-level (CRUD) or field-level security (FLS)—to enforce those, query with WITH USER_MODE or use Security.stripInaccessible().
Q14: What is Lightning Message Service (LMS)?
Lightning Message Service (LMS) is a publish-subscribe framework that enables communication across unrelated components on a single Lightning page—including across Lightning Web Components, Aura Components, and Visualforce pages embedded in iframes.
Q15: What is the SOQL 101 governor limit, and how do you prevent it?
The SOQL 101 limit (System.LimitException: Too many SOQL queries: 101) occurs when synchronous Apex executes more than 100 SOQL queries in a single transaction. It is almost always caused by putting a SOQL query inside a for loop. Always bulkify your code by collecting record IDs into a Set<Id> and querying outside the loop.
- Synchronous SOQL Queries: 100 queries maximum per transaction.
- Asynchronous SOQL Queries: 200 queries maximum per transaction.
- Total DML Statements: 150 statements maximum.
- Maximum Total Records Retrieved via SOQL: 50,000 records.
- Maximum CPU Time: 10,000 ms (synchronous) / 60,000 ms (asynchronous).