This question runs in a pre-configured Salesforce environment - no personal connection required.

Write a method that uses SOQL to join Accounts with their Contacts and return formatted strings showing the account name and contact name. The method should return a List of Strings in the format "Account Name - Contact Name", sorted alphabetically by the combined string.

This challenge tests your ability to work with SOQL relationship queries and string formatting to create meaningful data combinations.

Examples

Input: None (method queries all account-contact relationships) Output: [ 'Cloud Code Academy - Michael Johnson', 'Cloud Code Academy - Nina Petrov', 'Cloud Code Academy - Sarah Davis', 'TechFlow Solutions - Emily Martinez', 'TechFlow Solutions - Grace Kim', 'TechFlow Solutions - Robert Chen', ... ] Explanation: Returns formatted strings for each account-contact pair, sorted alphabetically Input: If accounts have no contacts Output: [] Explanation: Returns empty list when no contact relationships exist
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • This challenge runs without connecting your own org
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay July 2026

Contest runs July 1 - 31. Complete challenges to climb the leaderboard!

Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In