Batch Apex and Interview Question

question 1) what is Batch Apex in Salesforce?

answer- batch Apex is used to process large volumes of data asynchronously. It allows to run operation on records that exceed that normal governor limits by breaking the data into smaller manageable chunks.

question 2) What are the three method in a Batch Apex class?

answer-

start- retrieve the records to be processed.

execute- Processes each batch of records.

finish- Executes post-processing logic after the batch job is complete.

syntax- global calss BatchDemo implements Database.Batchable<sObject>{

global (Database.QueryLocator or Iterable<sObjecy>){

start(Database.BatchableContext bc){

}

global void execute(Database.batchableContext bc, List<sObject> scope){

}

global void finish(Database.BatchableContext bc){

}

}

}