58 Apex and Triggers questions based on real company interview experiences shared on this site (EY, Accenture, PwC, Cognizant, TCS, Persistent, Infosys, Tech Mahindra and more). Click an option to instantly see if you got it right – no submit button needed.
Topics: governor limits, sharing, trigger context and best practices, future vs Queueable vs Batch, testing, JSON, Apex sharing and more.
Score: 0 / 58
Question 1 of 58
What is the main purpose of Salesforce governor limits?
Question 2 of 58
What is the maximum number of SOQL queries allowed in a single synchronous Apex transaction?
Question 3 of 58
What is the maximum total number of records that SOQL queries can retrieve in a single synchronous transaction?
Question 4 of 58
What is the maximum number of DML statements allowed in one Apex transaction?
Question 5 of 58
What is a common way to avoid a Heap Size limit error in Apex?
Question 6 of 58
What does the with sharing keyword enforce on an Apex class?
Question 7 of 58
What does the inherited sharing keyword do on an Apex class?
Question 8 of 58
How can an Apex class be made to bypass the sharing rules of the current user?
Question 9 of 58
Which trigger context variable is NOT available in a before insert trigger?
Question 10 of 58
What does Trigger.newMap contain?
Question 11 of 58
In which trigger events are Trigger.old and Trigger.oldMap available?
Question 12 of 58
When should you use an after trigger instead of a before trigger?
Question 13 of 58
What is a common way to prevent a recursive trigger from running repeatedly in one transaction?
Question 14 of 58
Which of these is a recommended Apex trigger best practice?
Question 15 of 58
If two triggers exist on the same object for the same event, what is true about their execution order?
Question 16 of 58
If an exception occurs in an after trigger, what happens to the record being saved?
Question 17 of 58
Which approach is commonly used to bypass trigger execution for specific users or data loads?
Question 18 of 58
Which method is used in a before delete trigger to block a record from being deleted with a custom message?
Question 19 of 58
Which statement about future methods is correct?
Question 20 of 58
Which parameter types can a future method accept?
Question 21 of 58
Why can a future method not accept sObjects as parameters?
Question 22 of 58
Can a future method be called from a trigger?
Question 23 of 58
Can a future method be called from a Batch Apex job or from another future method?
Question 24 of 58
How many future method calls are allowed in a single Apex invocation?
Question 25 of 58
What is a key advantage of Queueable Apex over a future method?
Question 26 of 58
Can a Queueable class call a future method?
Question 27 of 58
How do you test Queueable Apex in a test class?
Question 28 of 58
Which interface must a class implement to be used as a Batch Apex job?
Question 29 of 58
What are the three methods of the Database.Batchable interface?
Question 30 of 58
What is the default batch size when Database.executeBatch() is called without a scope?
Question 31 of 58
What is the maximum batch size (scope) you can specify in Database.executeBatch()?
Question 32 of 58
A batch job processes 3000 records with a scope of 200. How many times will execute() run?
Question 33 of 58
What does Database.Stateful do in Batch Apex?
Question 34 of 58
How can you track the number of successful and failed records across a whole batch job?
Question 35 of 58
Can callouts be made from Batch Apex?
Question 36 of 58
Where should you chain (start) another batch job from a running batch job?
Question 37 of 58
Is Batch Apex synchronous or asynchronous?
Question 38 of 58
Up to how many batch jobs can be queued or active at once (extra jobs go to the Flex Queue, which holds up to 100)?
Question 39 of 58
What is the maximum number of records a Batch Apex QueryLocator can return?
Question 40 of 58
Which is a valid way to schedule a batch job?
Question 41 of 58
What is the difference between Schedulable Apex and Batch Apex?
Question 42 of 58
If one execute() chunk of a batch job throws an unhandled exception, what happens to the other chunks?
Question 43 of 58
Why do Apex test classes matter for deploying to production?
Question 44 of 58
What is the purpose of @testSetup in a test class?
Question 45 of 58
What does System.runAs() do in a test class?
Question 46 of 58
How do you test Apex code that makes an HTTP callout?
Question 47 of 58
Which exception is thrown when a DML operation fails?
Question 48 of 58
What is the difference between JSON.deserialize and JSON.deserializeUntyped?
Question 49 of 58
Which of these can dynamically enforce field-level security in Apex queries?
Question 50 of 58
What is Apex Managed Sharing?
Question 51 of 58
What happens if you insert a User and a Task in the same transaction?
Question 52 of 58
What is a wrapper class in Apex?
Question 53 of 58
Why are Maps often preferred over Lists in trigger scenarios?
Question 54 of 58
Which statement about Lists, Sets and Maps in Apex is correct?
Question 55 of 58
What is a constructor in Apex?
Question 56 of 58
How does Apex handle transaction rollback?
Question 57 of 58
Why must an Apex method used with @wire in LWC be marked cacheable=true?
Question 58 of 58
Which annotation exposes an Apex class as a REST web service?