ApexSensei

Blog

Apex Practice Problems for Beginners (Graded, in Order)

By Firus Hanov · · 6 min read

Ten short Apex practice problems, graded. Start with a drill that needs no Salesforce org, then strings, decimals, lists, and a class. Write Apex and Think in classes are free to Check and Run.

Apex Practice Problems for Beginners (Graded, in Order)

Apex practice problems only help if something checks the answer. Reading a Trailhead module and then staring at a blank Developer Console is how most people stall. The drills below are short, graded, and ordered so the first one does not need a Salesforce org at all.

Write Apex and Think in classes are free to Check and Run on ApexSensei. Start with the first one. Come back to this list when you want the next problem.

Start with a problem you can finish today

Comments that survive review is a pattern drill. You edit a short snippet, press Check code, and the grader looks at the comments you left. No login to Salesforce, no debug log, about five minutes.

That is the right first win. Syntax, a reason next to a line, and a block comment around scratch debug lines. If you can pass that, you can use the rest of the path.

The next drill, Hello, ApexSensei, is the first one that runs in your Developer org. It grades a USER_DEBUG line, not a screenshot. The setup for that org is in Your first Salesforce Developer org.

Ten problems that teach the language, not the platform

Stay inside Write Apex until these feel boring. Each one is one idea:

  1. Double a number and pick the larger number. Assignment and a branch.
  2. Greet by name and join a full name. Strings and null-safe habits.
  3. Is the name blank? and True, false, and null. Apex null is not false, and an empty string is not null.
  4. Money is a Decimal and Integer division and Math.mod. Currency in a Double will embarrass you later.
  5. Lists of Opportunities and Count Leads by Rating with a Map. This is the shape of every bulk trigger you will write.

Do them in order. The later drills assume the earlier variable names and the earlier mistakes.

Then write a class on purpose

Anonymous Apex throws the type away when the window closes. Build a Case summary class is the first drill where the code is shaped like a class you would keep. Think in classes is still free to Check and Run. Parameters, return values, and a read-only total are the next ten drills. Finish those before you touch a trigger.

What to skip until the free modules are done

SOQL, triggers, tests, and async Apex are on the path, and they are the right next problems. They are not the right first problems. Query the org, Automate with triggers, and Prove it with tests are free to read. Check and Run on those modules is Apex Path, $19 a month after a 7-day trial.

If you want the SOQL set after the free modules, start at SOQL practice problems. If you want the trigger set, start at Apex trigger practice problems. Both assume you can already pass a list drill and a class drill.

Practice Apex free on ApexSensei