ApexSensei

All drills

Classes & objects: Apex practice drills

Classes, constructors, methods, access modifiers, exceptions and enums.

Beginner · Free to run

  1. Build a Case summary class Beginner · 10 min

    A class groups fields and methods, and new builds a separate object for each case.

  2. Build queue labels with parameters Beginner · 10 min

    Parameters make one method reusable.

  3. Return a value and record work Beginner · 12 min

    A method's return type promises a value back to the caller.

  4. Initialize a service appointment Beginner · 12 min

    A constructor runs when new builds an object, so every new object starts with a valid state.

  5. Protect a support ticket subject Beginner · 12 min

    private fields plus public methods let the class enforce its own rules.

  6. Expose a read-only quote total Intermediate · 15 min

    Apex properties expose a value through get and set, and a getter-only property returns a derived value.

  7. Overload a Case label method Intermediate · 15 min

    Overloading is one method name with different parameter lists; Apex picks the version whose parameters match your call.

  8. Route Cases with an enum Intermediate · 15 min

    An enum is a type with a fixed set of named values.

  9. Recover from division by zero Intermediate · 15 min

    try holds code that might fail; a matching catch runs instead if it does, and later code still runs.

  10. Reject an invalid discount Intermediate · 18 min

    A custom exception gives a business rule its own type.

  11. Interface with two implementations Beginner · 14 min

    An interface is a contract: method signatures with no bodies.

  12. virtual, override and super Intermediate · 18 min

    A virtual method can be replaced by a subclass marked override, and super.method() runs the base version from inside the override.

  13. Constructor chaining with this(...) Intermediate · 14 min

    A class can have several constructors.

  14. finally and several catch blocks Intermediate · 14 min

    A try block can be followed by several catch blocks, one per exception type, and a finally block that runs no matter what.

  15. Static versus instance members Intermediate · 16 min

    static members belong to the class and are shared across every instance for the whole transaction.

  16. Extend an abstract score rule Intermediate · 16 min

    An abstract class can hold shared methods and leave one or more methods for a subclass to finish with override.

Start practicing free