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!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Note

You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.