Salesforce Platform Developer I (legacy) — Question 7
A developer executes the following query in Apex to retrieve a list of contacts for each account:
List<account> accounts = [Select ID, Name, (Select ID, Name from Contacts) from Account] ;
Which two exceptions may occur when it executes? (Choose two.)
Answer options
- A. CPU limit exception due to the complexity of the query.
- B. SOQL query row limit exception due to the number of contacts.
- C. SOQL query limit exception due to the number of contacts.
- D. SOQL query row limit exception due to the number of accounts.
Correct answer: B, D
Explanation
The correct answers B and D indicate that the exceptions are related to the limits set for the number of records returned in the query. Option B is valid since there's a row limit for the number of contacts that can be retrieved, while option D reflects the limit on the number of accounts that can be queried. Options A and C are incorrect because they do not pertain to the specific limits that apply to this scenario.