Salesforce Developer Interview Questions
Q:1 Asynchronus Apex
Ans: If we have to run some job that will take some time then in the case of synchronous apex we will get the limit error, heap size error, or timeout error. To avoid such issues, we can do those long-running or time-consuming operations using Asynchronous apex which will run in a separate thread and will not impact the main thread. So Asynchronous Apex is used to run the process in a separate thread at a later time.
Increase User Efficiency
More Heap Size and Higher Governer limit
Better Scalability
Batch Apex
Future methods
Queueable Apex
Scheduled Apex
More Heap Size and Higher Governer limit
Better Scalability
Batch Apex
Future methods
Queueable Apex
Scheduled Apex
Q.2 Where we can use Asynchronous Apex?
Sending Email to the user.
Calling an external system for multiple records
Schedule a job for a specific time
Chaining apex code execution which might use
Q. 3 Can a future method call another non-future method to process tasks like callouts, and have those methods return data to the future method for further processing?
No, we can not call future methods from the future method.
Q:4 How many Schedulable Apex jobs can you have at one time? In other words, what is the maximum number of Apex classes that can be scheduled concurrently?
100
Q:5 Why sObject parameters not supported in future methods?
The sObject might change between the time we call the method and the time it executes that’s why sObjects can’t be passed as arguments to future methods. In this case, the future method will get the old sObject values and might overwrite them.
Q:6 Can I call Queueable from a batch?
Yes, But it is limited to just one System.enqueueJob call per execute in the Database.Batchable class. Salesforce has imposed this limitation to prevent explosive execution.
Q:7 How Future method helps in avoiding Mixed DML errors?
There are 2 kinds of sObjects in salesforce.
1. Non-Setup: Account, opportunity, etc
2. Setup: User, groups,Queue etc
If we are performing DML on both kinds of sObject in a single transaction, the system doesn’t allow it and throws an exception called Mixed DML exception, stating that a transaction can not have a Mixture of DML operation(Setup and Non-Setup).
Q.8 What is Database.QueryLocator & Iterable<sObject>?
In Database.QueryLocator, we use a simple query (SELECT) to generate the scope of objects. The governor limit for the total number of records retrieved by SOQL queries is bypassed, i.e. it can return up to 50 million records.
In Iterable<sObject>, we can create a custom scope for processing, which would be not possible to create using SOQL where clauses. the governor limit for the total number of records retrieved by SOQL queries is still enforced.


0comments
Post a Comment