Question 1 of 30
In a Salesforce Apex class, you are tasked with implementing a control structure that processes a list of account records. Each account has a field called `AnnualRevenue`. You need to categorize these accounts into three groups based on their revenue: \"High\" for accounts with revenue greater than $1,000,000, \"Medium\" for accounts with revenue between $500,000 and $1,000,000, and \"Low\" for accounts with revenue less than $500,000. If you have a list of accounts, how would you structure your control flow to efficiently categorize these accounts and store the results in a map where the key is the revenue category and the value is a list of account IDs?
Use a for loop to iterate through the accounts, and within the loop, use if-else statements to check the revenue and add the account ID to the corresponding list in the map.
Use a while loop to iterate through the accounts, and within the loop, use a switch statement to categorize the accounts based on their revenue.
Use a for-each loop to iterate through the accounts, and within the loop, use a nested for loop to check the revenue against predefined thresholds.
Use a do-while loop to iterate through the accounts, and within the loop, use a series of ternary operators to categorize the accounts.

Preparing for SalesForce DEV-401 Building Applications with Force. com and Visualforce? Now land the interview.

73% of qualified candidates get rejected because of weak resumes. Build an ATS-optimized, recruiter-ready resume in under 5 minutes - free to start.

Build My Resume Free