Skip to main content

Top 15 Salesforce Developer Interview Questions and Answers (Apex, Asynchronous Limits & Lightning)

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.

In plain words: Salesforce technical interviews test your real-world problem solving: how you process high-volume data within execution limits, decouple integrations, and coordinate communication across UI components.

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.
Real-Life Scenario: If your batch's 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).

Developer Trap: If you need asynchronous processing from a Batch class, invoke Queueable Apex from the 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 an AsyncApexJob ID 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 Holding status.
  • Use Database.Stateful in 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) to false allows valid records to save while logging failed records in a Database.SaveResult[] array.

3. Lightning Frameworks (Aura & LWC)

Q7: How do you handle page navigation in Lightning?

  • Lightning Web Components (LWC): Use the lightning/navigation service with the NavigationMixin wrapper to navigate to record pages, list views, or external URLs.
  • Aura: Use the lightning:navigation component service alongside pageReferenceUtils.

Q8: How do you display dynamic modal dialogs in Lightning?

  • In Modern LWC: Extend LightningModal to create clean, promise-based modal containers that pass return values back to the invoking component upon closing.
  • In Legacy Aura: Use the lightning:overlayLibrary service 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) or force:lightningQuickActionWithoutHeader (custom modal framing).
  • LWC: Configure your component's XML metadata (.js-meta.xml) with target lightning__RecordAction and set actionType to ScreenAction or Action.

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 @api methods 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 in INSERT, UPDATE, and UNDELETE triggers.
  • Trigger.newMap: Returns a map of IDs to the new versions of the sObject records (Map<Id, sObject>). Available only in AFTER INSERT, BEFORE UPDATE, AFTER UPDATE, and AFTER UNDELETE triggers (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.

Apex Governor Limits Cheat Sheet:
  • 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).
Core Takeaway: Always bulkify your Apex triggers, leverage Queueable Apex for asynchronous operations, and use modern LWC constructs for efficient UI data binding.