Process Automation and Logic28% of the exam
Apex variables, modifiers, methods and interfaces
How to declare Apex variables and static final constants, which access modifier exposes a member to whom, static versus instance members, method rules, and when to use an interface, a virtual class or an abstract class, plus what the sharing keywords declare.
Understand how to declare variables, constants, methods, modifiers, Apex interfaces, and the appropriate use cases for each.
~8 min read · 9 practice questions ·
What the exam expects
- Declare local and class variables, predict their initial value and scope, and declare a constant that other classes read through the class name.
- Pick the narrowest access modifier (private, protected, public, global) for a requirement, and reach a private member from a test without widening it.
- Decide between static and instance members, and predict how long a static value lives.
- Choose an interface, a virtual class or an abstract class from a design requirement, including sorting with
Comparable. - State what
with sharing,without sharing,inherited sharingand an omitted declaration mean for a class.
Key terms: constant (a static final variable); access modifier (who can see a member); virtual (extendable, with overridable default bodies); abstract (declares bodiless methods a subclass must supply); interface (method signatures only, a new data type).
Key facts
Uninitialized variable
- Detail
- null, including Boolean (not false) and Integer (not 0)
Identifiers
- Detail
- Variable and method names are case-insensitive
Constant
- Detail
static final; assigned once, in the declaration or a static block
Default member access
- Detail
- private
protected
- Detail
- Inner classes and extending classes; instance members only
global member
- Detail
- Its class must also be global
Static variable lifetime
- Detail
- One transaction; reset at the boundary
Method parameters
- Detail
- At most 32
Inheritance
- Detail
- Extend one class; implement many interfaces
Comparable
- Detail
- Implement public or global
compareTo(Object); thenList.sort()
inherited sharing entry point
- Detail
- Runs as with sharing unless called from a without sharing context
Sources for this section (8)
- Variablesdeveloper.salesforce.com (opens in a new tab)
- Constantsdeveloper.salesforce.com (opens in a new tab)
- Access Modifiersdeveloper.salesforce.com (opens in a new tab)
- Static and Instancedeveloper.salesforce.com (opens in a new tab)
- Class Methodsdeveloper.salesforce.com (opens in a new tab)
- Apex Class Definitiondeveloper.salesforce.com (opens in a new tab)
- Comparable Interfacedeveloper.salesforce.com (opens in a new tab)
- Sharing Keywordsdeveloper.salesforce.com (opens in a new tab)
- What value does `Boolean b;` hold before assignment?
- Why is a static variable safe as a recursion flag but useless as a cache?
- When should you choose a virtual class over an interface?
- Which modifier exposes a member to extending classes but not to unrelated classes?
- Why declare `with sharing` explicitly instead of omitting the keyword?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Platform Developer pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 21 lessons of the Platform Developer guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (9 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams