InterviewPitch

Land the job you want — prepare
with Real interviews Q&A

Curated interview questions, company-wise guides and coding rounds. Practice mock interviews, improve with feedback, and track your progress.

Q&A
Top curated interview packs
Company-wise & role-wise packs, quality assured.
Mock interview
AI scoring
Coding rounds
Top 10 sets
Beginner
2. What are the key features of Apex?

Apex is object-oriented, strongly typed, multitenant aware, integrated directly with the database, and provides built-in support for transactional triggers as well as complex asynchronous processing loops.

Apex

Account acc = new Account(Name = 'Acme Corp');
insert acc;
Beginner
3. What is a Governor Limit?

Governor limits are runtime limits enforced by the Salesforce multitenant engine to prevent shared execution threads from monopolizing system resources.

Apex

// Bulkified query and list insert
List<Contact> contactsToInsert = new List<Contact>();

for (Account acc : [SELECT Id FROM Account LIMIT 100]) {
    contactsToInsert.add(
        new Contact(
            LastName = 'Doe',
            AccountId = acc.Id
        )
    );
}

insert contactsToInsert;
Beginner
4. What is SOQL?

SOQL (Salesforce Object Query Language) is used to read data structures and records from individual object structures.

Apex

List<Opportunity> opps = [
    SELECT Id, Name, Amount, StageName
    FROM Opportunity
    WHERE CloseDate = TODAY
];
Beginner
5. What is SOSL?

SOSL (Salesforce Object Search Language) is used to scan text patterns across multiple index tables at once.

Apex

List<List<SObject>> searchList = [
    FIND 'Acme*'
    IN ALL FIELDS
    RETURNING
        Account(Name),
        Contact(FirstName, LastName)
];
Beginner
6. Difference between SOQL and SOSL?

SOQL retrieves exact records from a single object index, whereas SOSL performs multi-object keyword searches efficiently across text columns.

Apex

// SOQL (Exact retrieval)
Account acc = [
    SELECT Id
    FROM Account
    WHERE Name = 'Acme'
    LIMIT 1
];

// SOSL (Fuzzy search)
List<List<SObject>> results = [
    FIND 'Acme'
    IN NAME FIELDS
    RETURNING Account(Id, Name)
];
Beginner
7. What is a Trigger in Apex?

A trigger is Apex code that runs dynamically before or after specific DML operations, such as record insertions, edits, or removals.

Apex

trigger AccountTrigger on Account (before insert, before update) {

    for (Account acc : Trigger.new) {

        if (acc.Industry == null) {
            acc.Industry.addError('Industry is required.');
        }

    }

}
Beginner
8. What are DML statements?

Data Manipulation Language statements modify records in the Salesforce database (e.g., insert, update, delete, undelete, upsert).

Apex

List<Account> newAccs = new List<Account>{
    new Account(Name = 'Tech Corp'),
    new Account(Name = 'Media Group')
};

insert newAccs;
Beginner
9. What is a Class in Apex?

A class is a structural template or object-oriented blueprint containing processing methods and properties.

Apex

public class Vehicle {

    private String model;

    public Vehicle(String modelName) {
        this.model = modelName;
    }

}
Beginner
10. What are Access Modifiers in Apex?

Apex provides four levels of visibility control: public, private, protected, and global.

Apex

global class GlobalService {

    public static void performTask() {

        // Shared across namespaces and API integrations

    }

}
Beginner
11. What is a Static variable?

A static variable is scoped to the class itself rather than individual instances, and persists across execution contexts.

Apex

public class Counter {

    public static Integer staticCount = 0; // Class-level shared state

    public Integer instanceCount = 0; // Object-level individual state

}
Beginner
12. What is a Constructor?

A constructor is a special class method called automatically during object instantiation to initialize state.

Apex

public class Employee {

    public String name;

    public Employee(String empName) {
        this.name = empName;
    }

}
Beginner
13. What is Batch Apex?

Batch Apex processes massive datasets asynchronously by splitting operations into smaller, manageable transaction blocks called chunks.

Apex

public class AccountUpdateBatch implements Database.Batchable<SObject> {

    public Database.QueryLocator start(Database.BatchableContext bc) {

        return Database.getQueryLocator(
            'SELECT Id FROM Account'
        );

    }

    public void execute(
        Database.BatchableContext bc,
        List<Account> scope
    ) {

        // Process each chunk safely

    }

    public void finish(Database.BatchableContext bc) {

        // Post-processing logic

    }

}
Beginner
14. What is a Future Method?

A future method (annotated with @future) executes asynchronously in its own thread block when resources become available.

Apex

public class AsyncHelper {

    @future
    public static void callExternalWebService(String payload) {

        // Async processing

    }

}
Beginner
15. What is a Test Class?

A test class contains verification logic to test Apex code functionality, and is required to hit a minimum 75% code coverage threshold for production deployments.

Apex

@isTest
private class AccountServiceTest {

    @isTest
    static void testAccountCreation() {

        Account acc = new Account(Name = 'Test Acc');

        insert acc;

        System.assertNotEquals(
            null,
            acc.Id,
            'Account ID should be generated'
        );

    }

}
Intermediate
16. What is Bulkification?

Bulkification is the practice of designing code to handle sets of records efficiently in a single operation, rather than processing individual records one-by-one inside loop blocks.

Apex

// BAD (Trigger with nested query)

// for (Account a : Trigger.new) {
//     List<Contact> c = [
//         SELECT Id
//         FROM Contact
//         WHERE AccountId = :a.Id
//     ];
// }

// GOOD (Bulkified query mapping)

Set<Id> accIds = new Set<Id>();

for (Account a : Trigger.new) {
    accIds.add(a.Id);
}

List<Contact> contacts = [
    SELECT Id, LastName
    FROM Contact
    WHERE AccountId IN :accIds
];
Intermediate
17. What is a Wrapper Class?

A wrapper class is a custom container object used to bind multiple distinct data types or sObjects together into a single logical structure.

Apex

public class TableWrapper {

    public Account accRecord { get; set; }

    public Boolean isSelected { get; set; }

    public TableWrapper(Account a) {

        this.accRecord = a;
        this.isSelected = false;

    }

}
Intermediate
18. What is a Map in Apex?

A map is an un-ordered collection that stores data in key-value pairs, where each key uniquely maps to a single corresponding value.

Apex

Map<Id, Account> accountMap =
    new Map<Id, Account>([
        SELECT Id, Name
        FROM Account
        LIMIT 10
    ]);

Account target =
    accountMap.get('0018000000GvNX0AAN');
Intermediate
19. What is a Set in Apex?

A set is an unordered collection of elements that enforces uniqueness, preventing duplicate entries from being added to the collection.

Apex

Set<String> uniqueCodes =
    new Set<String>{
        'US',
        'UK',
        'CA',
        'US'
    };

System.debug(uniqueCodes.size()); // Outputs 3
Intermediate
20. What is a List in Apex?

A list is an ordered collection of elements indexed by position. It can contain duplicate values and functions like a standard dynamic array.

Apex

List<String> names = new List<String>();

names.add('Akash');
names.add('Rahul');

String first = names.get(0);
Intermediate
21. What is Queueable Apex?

Queueable Apex is an asynchronous design pattern that builds upon future methods, allowing you to monitor job status and chain sequential asynchronous execution flows.

Apex

public class AsyncProcessor implements Queueable {

    public void execute(QueueableContext context) {

        // Chainable async operation
        System.enqueueJob(new SecondaryProcessor());

    }

}
Intermediate
22. What is SObject?

An sObject is a generic data type that can represent any standard or custom Salesforce object record in memory.

Apex

sObject genericRecord =
    new Account(Name = 'Generic Corp');

String objName =
    genericRecord
        .getSObjectType()
        .getDescribe()
        .getName();
Intermediate
23. What is Schema Builder?

Schema Builder is a visual design utility inside Salesforce used to manage data models, define objects, and establish relationship connections. At the code level, you describe these schemas programmatically.

Apex

Map<String, Schema.SObjectType> gd =
    Schema.getGlobalDescribe();

Schema.DescribeSObjectResult descResult =
    gd.get('Account').getDescribe();
Intermediate
24. What is With Sharing?

The with sharing keyword enforces the organization-wide defaults and sharing rules of the running user for all database queries and transactions in that class.

Apex

public with sharing class SecureRecordController {

    // Respects sharing rules
    // of current logged-in user

}
Intermediate
25. What is Without Sharing?

The without sharing keyword executes class logic in system mode, ignoring the current user's sharing rules and record permissions.

Apex

public without sharing class AdminDataOverrider {

    // Skips sharing rules
    // and operates with system-level access

}
Intermediate
26. What is Upsert?

The upsert command checks if a record exists based on an ID or unique external ID field; it updates the record if found, or inserts a new record if it is not.

Apex

Account acc = new Account(
    Name = 'Upsert Corp',
    External_ID__c = 'EXT-101'
);

upsert acc External_ID__c;
Intermediate
27. What is Database Class?

The Database class provides system methods for database manipulation, supporting partial successes via the allOrNone parameter option.

Apex

Database.SaveResult[] srList =
    Database.insert(accountList, false);

// false allows partial success
Intermediate
28. What is Trigger Context Variable?

Trigger context variables (e.g., Trigger.new, Trigger.oldMap, Trigger.isInsert) provide operational state and data from the triggering transaction.

Apex

trigger ContactTrigger on Contact (before update) {

    for (Contact newCon : Trigger.new) {

        Contact oldCon =
            Trigger.oldMap.get(newCon.Id);

        if (newCon.Email != oldCon.Email) {

            System.debug(
                'Email changed from '
                + oldCon.Email
            );

        }

    }

}
Intermediate
29. What is Callout in Apex?

A callout executes HTTP requests from Apex to integrate and exchange payload data with external web services.

Apex

Http http = new Http();

HttpRequest request = new HttpRequest();

request.setEndpoint(
    'https://api.example.com/data'
);

request.setMethod('GET');

HttpResponse response =
    http.send(request);
Intermediate
30. What is Exception Handling?

Exception handling uses try-catch-finally blocks to intercept runtime errors, handle failures gracefully, and execute mandatory cleanup actions.

Apex

try {

    insert new Lead(LastName = 'Smith');

}
catch (DmlException e) {

    System.debug(
        'DML failed: ' + e.getMessage()
    );

}
finally {

    System.debug(
        'Transaction finished processing.'
    );

}
Advanced
31. What is Lightning Web Component integration with Apex?

Apex methods annotated with @AuraEnabled allow client-side Lightning Web Components (LWC) to call server-side actions, retrieve database records, or trigger business logic.

Apex

public class ContactController {

    @AuraEnabled(cacheable=true)
    public static List<Contact> getContactList() {

        return [
            SELECT Id, FirstName, LastName
            FROM Contact
            LIMIT 10
        ];

    }

}
Advanced
32. What is Platform Event?

Platform Events support an event-driven architecture, enabling applications to run independently by publishing and subscribing to real-time notification streams.

Apex

Order_Event__e eventObj =
    new Order_Event__e(
        Order_Id__c = 'ORD-009',
        Status__c = 'Shipped'
    );

Database.SaveResult sr =
    EventBus.publish(eventObj);
Advanced
33. What is Mixed DML Error?

A Mixed DML error occurs when you try to modify a setup object (like User) and a non-setup object (like Account) in the same transaction context.

Apex

User u = [
    SELECT Id
    FROM User
    WHERE Alias = 'admin'
];

System.runAs(u) {

    // Update User (Setup Object)

}

// Update Account (Non-Setup Object)
// outside block
Advanced
34. What is Apex Scheduler?

The Apex Scheduler executes specific classes at scheduled intervals by implementing the Schedulable interface.

Apex

public class CleanupScheduler
    implements Schedulable {

    public void execute(SchedulableContext sc) {

        // Delete orphaned logs dynamically

    }

}
Advanced
35. What is Custom Metadata Type?

Custom Metadata Types are application configurations that can be packaged and deployed between environments. They are read from cache without consuming SOQL query limits.

Apex

App_Setting__mdt setting =
    App_Setting__mdt.getInstance(
        'Global_Config'
    );

Boolean featureEnabled =
    setting.Is_Active__c;
Advanced
36. What is Field-Level Security?

Field-Level Security (FLS) manages user access to specific fields on objects. It should be validated dynamically in Apex before querying or mutating field data.

Apex

if (
    Schema.sObjectType.Contact
        .fields.Email.isAccessible()
) {

    // Query/Read field safely

}
Advanced
37. What is Dynamic SOQL?

Dynamic SOQL allows you to construct and execute SOQL query strings at runtime using the Database.query() method.

Apex

String dynamicField = 'Phone, Email';

String queryStr =
    'SELECT Id, '
    + dynamicField
    + ' FROM Lead LIMIT 5';

List<Lead> leads =
    Database.query(queryStr);
Advanced
38. What is Savepoint?

A Savepoint defines a specific state in a transaction that you can roll back to in case of errors, without reverting the entire transaction.

Apex

Savepoint sp =
    Database.setSavepoint();

try {

    insert new Account(
        Name = 'Success'
    );

    insert new Contact();

    // Fails due to missing LastName

}
catch (Exception e) {

    Database.rollback(sp);

    // Reverts transaction

}
Advanced
39. What is a Custom Setting?

Custom Settings are application configurations cached in memory. They provide fast read access without using SOQL query limits.

Apex

Discount_Setting__c discount =
    Discount_Setting__c.getInstance();

Decimal rate =
    discount.Global_Rate__c;
Advanced
40. What is CRUD and FLS in Apex?

CRUD permissions control user access to entire objects, while FLS permissions control user access to specific fields on those objects.

Apex

if (
    Schema.sObjectType.Account.isCreateable()
    &&
    Schema.sObjectType.Account
        .fields.Rating.isCreateable()
) {

    insert new Account(
        Name = 'Protected Inc',
        Rating = 'Hot'
    );

}
Coding Round
41. Query Accounts using SOQL
Apex

List<Account> accs = [
    SELECT Id, Name
    FROM Account
];
Coding Round
42. Insert a record
Apex

Account acc =
    new Account(Name='Test');

insert acc;
Coding Round
43. Update a record
Apex

acc.Name = 'Updated';

update acc;
Coding Round
44. Delete a record
Apex

delete acc;
Coding Round
45. Future method example
Apex

@future
public static void asyncMethod() {

    // Long running asynchronous process

}
Coding Round
46. Batch Apex structure
Apex

global class MyBatch
    implements Database.Batchable<SObject> {

    global Database.QueryLocator start(
        Database.BatchableContext BC
    ) {

        return Database.getQueryLocator(
            'SELECT Id FROM Account'
        );

    }

    global void execute(
        Database.BatchableContext BC,
        List<Account> scope
    ) {

        // Batch chunks executed here

    }

    global void finish(
        Database.BatchableContext BC
    ) {

        // Cleanup actions

    }

}
Coding Round
47. Trigger example
Apex

trigger AccountTrigger on Account (
    before insert
) {

    for (Account acc : Trigger.new) {

        // Before insert logic

    }

}
Coding Round
48. Queueable Apex
Apex

public class MyQueue
    implements Queueable {

    public void execute(
        QueueableContext context
    ) {

        // Async processing

    }

}
Coding Round
49. Dynamic SOQL example
Apex

String q =
    'SELECT Id FROM Account';

List<Account> accs =
    Database.query(q);
Coding Round
50. Exception handling
Apex

try {

    // Execution with risk

}
catch (DmlException e) {

    System.debug(
        'Exception: ' + e.getMessage()
    );

}