Salesforce Certified Platform Developer II — Question 122
[FIND 'map' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead]
What is a valid return type for the following SOSL query?
Answer options
- A. List<sObject>
- B. List<List<sObject>>
- C. List<AggregateResult>
- D. List<Account>
Correct answer: B
Explanation
The correct return type for a SOSL query that searches across multiple objects is List<List<sObject>>, as it returns a list of lists, where each inner list corresponds to the results from a specific object type. The other options are incorrect because List<sObject> does not accommodate the multiple object types returned, List<AggregateResult> is used for aggregate queries, and List<Account> only represents Account records, missing the other object types queried.