SF-PD2 Advanced Developer Fundamentals Practice Question
A developer is writing Apex tests for a service class that processes a collection of Account records. The test method must verify that the class correctly handles governor limits by checking how many SOQL queries were used. Which method should the developer call to obtain this information?
⚠ Common exam trap
Many candidates confuse the method that returns the current usage count with the one that returns the maximum allowed limit.
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
✓
Limits.getQueries()
The Limits class provides methods to monitor governor limit consumption. Limits.getQueries() returns the count of SOQL queries executed in the current transaction, enabling precise assertions in tests. The other methods either return the maximum limit, do not exist, or track a different resource (DML). Thus, Limits.getQueries() is the correct method for verifying SOQL query usage.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Limits.getLimitQueries()
Why it's wrong here
Limits.getLimitQueries() returns the total number of SOQL queries allowed for the transaction (e.g., 100), not the number already used. While useful for understanding the maximum allowed, it does not provide the actual count of queries executed, so it cannot be used to verify how many queries the service class performed.
- ✗
System.getQueries()
Why it's wrong here
System.getQueries() does not exist in Apex. The System class provides methods like debug(), assert(), and now(), but it does not offer a method to retrieve governor limit usage. Attempting to call this would result in a compile error, so it is not a valid option for checking SOQL query counts.
- ✗
Limits.getDmlStatements()
Why it's wrong here
Limits.getDmlStatements() returns the number of DML statements executed, not SOQL queries. This method is useful for monitoring DML operations, but the test scenario specifically requires tracking SOQL queries. Using this would give incorrect information about the service class's query behavior.
- ✓
Limits.getQueries()
Why this is correct
Limits.getQueries() returns the number of SOQL queries issued in the current transaction, which allows the test to assert that the class stays within limits. This method is part of the Limits class and is specifically designed for monitoring governor limit usage during execution, making it the correct choice for verifying query consumption in a test.
About these practice questions
One of 226 original SF-PD2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.