SF-PD2 Testing, Debugging, and Deployment Practice Question
Exhibit
{
"status": "failed",
"errorCode": "CIRCULAR_DEPENDENCY_DETECTED",
"message": "Apex Class A refers to Class B, and Class B refers to Class A.",
"deployment_id": "0Af123456789"
}Refer to the exhibit. A developer attempts a deployment using Salesforce CLI. The deployment fails with the circular dependency error shown. What is the root cause of this failure?
⚠ Common exam trap
Candidates mistakenly look for syntax errors or profile permission issues when encountering circular dependencies, missing the interlocked class references entirely.
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 classes share a cyclic reference, preventing the compiler from determining the initialization order.
Circular dependencies occur when two Apex classes reference each other's static methods or class variables directly. During compilation, the Apex compiler cannot resolve the symbols because each class requires the other to be compiled first. This scenario highlights the importance of modular design and the use of interfaces or abstract classes to decouple interdependent logic, which allows the deployment to proceed smoothly.
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 classes are missing the 'global' access modifier.
Why it's wrong here
The 'global' modifier is unrelated to circular dependency errors. It is used to expose classes to external namespaces or managed packages. Changing access modifiers will not resolve the underlying issue where the compiler cannot determine the order of dependency between two classes that reference each other's code.
- ✗
The deployment is using a source-format package that lacks a proper 'package.xml' file.
Why it's wrong here
While 'package.xml' is necessary for metadata-format deployments, the error message clearly indicates a code-level dependency conflict rather than a packaging configuration issue. The circular dependency is a logic error within the Apex source code itself, not an error related to how the files are grouped during the migration.
- ✓
The classes share a cyclic reference, preventing the compiler from determining the initialization order.
Why this is correct
Apex classes cannot have direct circular references because the compiler must resolve all dependencies before successful class compilation. When Class A calls Class B and Class B calls Class A, the system cannot verify the types and methods during the build phase, resulting in the reported deployment failure.
- ✗
The test classes for these Apex classes were not included in the deployment package.
Why it's wrong here
Test class inclusion is required for passing deployment validation, but the error message specifically identifies a circular dependency in the source classes. Omitting test classes would result in a 'missing coverage' error, not a circular dependency error. The issue is strictly located within the primary business logic classes.
Visual reference
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.