Lirik Infotech – Salesforce Developer Interview Questions
What's Covered
Topics covered in this interview.
All Interview Questions
Every question asked in this interview, listed one by one.
Preparing for a Salesforce developer interview?
Browse more real company interview experiences and hands-on Apex trigger patterns.
Quick answers to key questions
Short answers to the technical questions above. For project, certification and team questions, answer from your own experience.
Lightning Web Components
- Application event and component event. A component event is used between a component and its parents in the same hierarchy, for example a child telling its parent that a button was clicked. An application event is broadcast to any component that listens, so it suits unrelated components. Both are Aura concepts. In LWC, use custom events for child to parent, and Lightning Message Service for unrelated components.
- How to pass data between components in LWC. From parent to child, use a public property marked
@api. From child to parent, dispatch a custom event. For unrelated components, use Lightning Message Service.
Create a picklist in LWC
Use the lightning-combobox base component with an array of label and value pairs.
<!-- html -->
<template>
<lightning-combobox
label="Rating"
value={selected}
options={options}
onchange={handleChange}>
</lightning-combobox>
</template>
// js
import { LightningElement } from 'lwc';
export default class RatingPicklist extends LightningElement {
selected = 'Hot';
options = [
{ label: 'Hot', value: 'Hot' },
{ label: 'Warm', value: 'Warm' },
{ label: 'Cold', value: 'Cold' }
];
handleChange(event) {
this.selected = event.detail.value;
}
}To load the values of a real picklist field, use the getPicklistValues wire adapter instead of a fixed array.
Apex and triggers
- Future and queueable. A future method is simple, returns nothing and accepts only primitive parameters. A queueable class accepts complex types such as sObjects, returns a job Id so you can monitor it, and can chain another job. Use future for a quick callout or to avoid a mixed DML error, and queueable when the job needs objects or follow-up jobs.
- What is batch Apex, with a use case? Batch Apex processes a large number of records in chunks, each in its own transaction. A typical use case is a nightly job that cleans or updates millions of records, such as setting expired records to inactive.
- What is heap size? The memory that your variables use during a transaction. The limit is 6 MB for synchronous code and 12 MB for asynchronous code. To avoid the error, query only the fields you need, process records in a SOQL for loop or in batches, and clear large collections when you no longer need them.
- Test class best practices. Use
@isTest, create your own data (do not useSeeAllData=true), test positive, negative and bulk cases, useTest.startTest()andTest.stopTest(), useSystem.runAs()for permissions, and assert the results. - Trigger best practices. One trigger per object, logic in a handler class, bulkified code, no SOQL or DML in loops, and a way to avoid recursion.
- Platform events. Custom event messages used for event-driven integration. You publish them from Apex, flows or APIs, and subscribers such as triggers, flows, LWC and external systems react to them.
- Mixed DML. It happens when a setup object (for example User) and a non-setup object (for example Account) are changed in one transaction. Do one of them in a future method or queueable job.
Recursive trigger and how to avoid it
A recursive trigger fires again and again because its own DML triggers it again. Stop it with a static variable.
public class TriggerControl {
public static Boolean hasRun = false;
}
trigger AccountTrigger on Account (after update) {
if (TriggerControl.hasRun) return;
TriggerControl.hasRun = true;
// logic that updates records
}A single Boolean can skip legitimate records in the same transaction, so for bulk work store the Ids that you have already processed in a static Set.
Visualforce
- What is view state and how to reduce it? The hidden data that a Visualforce page sends back and forth to remember its state. Reduce it with
transientvariables, smaller collections, and by not storing query results you do not need. - actionFunction and actionStatus.
apex:actionFunctioncalls a controller method from JavaScript and can rerender part of the page.apex:actionStatusshows a message or spinner while that request is running. - Copy a value from one picklist to another. Add
apex:actionSupportwith theonchangeevent to the first picklist. It calls a controller method that copies the value to the property bound to the second picklist, and rerenders that field.
Other
- What is a Knowledge article? A record in Salesforce Knowledge that holds help or support content. It goes through draft, review and published stages and can be shared with agents, customers or partners.
- Scrum process. An agile method where work is done in short sprints (usually 2 to 4 weeks). The roles are Product Owner, Scrum Master and the development team. The main events are sprint planning, daily stand-up, sprint review and retrospective, and work comes from a prioritised product backlog.