ApexSensei

Drills › Write Apex

Store the company name

Write Apex · Beginner · 5 min · Runs in the browser, no org needed · Free

Scenario. A setup script still has an empty company name. Store the real name before anything else reads it.

Save a company name in a String, with single quotes and a semicolon.

What you will learn

A String holds text. Write the text in single quotes and end the statement with a semicolon.

String city = 'Denver';

Gotcha. null means no text yet. A name in quotes is a value the rest of the script can use.

The task

Give the company a name by replacing the empty companyName value.

Examples:

  • String city = 'Denver'; → city holds the text Denver
  • String companyName = null; → companyName holds no text yet

Requirements:

  1. Set companyName to RidgePoint Capital.
  2. Keep the String type and the variable name.
  3. Use single quotes around the name and end the line with a semicolon.
  4. Leave the other variables as they are.

Starter code

String companyName = null;
String city = 'Denver';
String industry = 'Finance';
Boolean active = true;

When it passes

`companyName` is the String `RidgePoint Capital`, in single quotes, and it is no longer null.

Try this drill free

You write the Apex yourself. ApexSensei runs it and tells you what passed and what did not.

‹ Comments that survive review · Count open cases ›