Think in classes: Apex practice drills
Classes, constructors, methods, access modifiers, exceptions and enums.
10 drills · Beginner · Free to run
- Build a Case summary class (Beginner, 10 min)
Write a small class, create separate Case summary objects, and call a method on each one. - Build queue labels with parameters (Beginner, 10 min)
Pass different owner names and Case counts into one reusable method. - Return a value and record work (Beginner, 12 min)
Contrast a method that returns a Lead action with a void method that changes state. - Initialize an appointment plan (Beginner, 12 min)
Use a constructor to set up an appointment plan and enforce a minimum length. - Protect a support ticket subject (Beginner, 12 min)
Keep ticket fields private and change them only through a public method that checks the input. - Expose a read-only quote total (Intermediate, 15 min)
Use Apex properties to protect a subtotal and work out a read-only total with tax. - Overload a Case label method (Intermediate, 15 min)
Give one method several parameter lists for normal, urgent, and aged Cases. - Route Cases with an enum (Intermediate, 15 min)
Model a fixed set of Case priorities, route each one with switch, and loop over them with values(). - Recover from division by zero (Intermediate, 15 min)
Call a calculator inside try/catch, catch the divide-by-zero MathException, and keep going. - Reject an invalid discount (Intermediate, 18 min)
Throw a custom exception when a discount is outside 0 to 50 percent, and print its message.