Important Aspects of Batch Apex

1) What access modifier we should use in Batch Class?
Ans: Global

2) What are the Methods we should Implement in Batch apex?
Ans:
Start:
global Database.Querylocator start (Database.BatchableContext bc){}
Execute:
global void execute(Database.BatchableContext bc,List <p>){}
Finish:
global void finish(Database.BatchableContext bc) {}

3) What is the Use of Start method?
Ans: It collect the records or objects to be passed to the interface method execute.

4) What is the importance of Execute method? and how many times it runs?
Ans: Contains or calls the main execution logic for the batch job. Execute method is called for  each batch of records.
For example if if you have 1000 record and having batch size of 200 each, then your execute method will run 5 times.

5) What is the purpose of finish method?
Ans: finish method executes after all batches are processed. Use this method to send confirmation email notifications.

6) What is a Database.Batchable interface?
Ans: The class that implements this interface can be executed as a batch Apex job.

7) What is a Database.QueryLocator?
Ans: If we use a Database.QueryLocator,
the governor limit for the total number of records retrieved by SOQL queries is bypassed. 
(Default 50,000 It allow up to 50 million records).

Comments

Popular Posts