SF-PD2 Testing, Debugging, and Deployment Practice Question
Exhibit
{
"rule": "AccountTriggerHandler",
"error": "Maximum stack depth reached",
"line": 42,
"trace": "AccountTriggerHandler.updateParent -> AccountTriggerHandler.updateParent"
}Refer to the exhibit. A developer encounters a 'Maximum stack depth reached' error. What is the most likely cause of this recursive error?
⚠ Common exam trap
Many candidates incorrectly attribute this error to infinite loops in logic rather than the specific Salesforce trigger recursion caused by DML operations within the same trigger context.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The trigger logic performs a DML operation that causes the same trigger to fire again.
This error indicates infinite recursion, where a trigger fires, updates a record, and that update triggers the same logic again. The stack trace shows the method calling itself. This is a common issue in Salesforce triggers and must be handled using static boolean flags or check variables to ensure that logic only executes once per transaction, preventing circular loops that exhaust system resources.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The code is using a SOQL query inside a loop, exceeding the limit.
Why it's wrong here
SOQL queries in loops cause a 'Too many SOQL queries' error, not a stack depth error. While bad practice, it does not lead to recursive stack overflow. The 'Maximum stack depth' message is specific to recursion and infinite method call loops that exceed the system's recursive call limit of 16.
- ✓
The trigger logic performs a DML operation that causes the same trigger to fire again.
Why this is correct
When an Apex trigger executes DML on the same object that triggered it, it causes the trigger to re-enter its own execution block. Without a static control variable to stop this recursion, the trigger fires infinitely until it hits the stack depth limit, which is exactly what the error message indicates.
- ✗
The trigger is processing too many records in a single batch, exceeding 200.
Why it's wrong here
Processing more than 200 records in a trigger would typically result in hitting the DML or CPU time limit, not the stack depth limit. The stack depth limit is specifically related to the number of nested method calls or recursive entries, not the volume of data being processed in one go.
- ✗
The code is attempting to access a field that does not exist in the current scope.
Why it's wrong here
Accessing a non-existent field results in a 'SObjectException' or a compilation error. It does not lead to a 'Maximum stack depth' error. The stack depth error is strictly reserved for scenarios where the execution context grows uncontrollably due to repeated method calls, usually caused by poor recursion management in triggers.
About these practice questions
Courseiva writes every SF-PD2 question from scratch — 226 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Salesforce exam blueprint
This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.