Access Modifiers - Private vs Protected vs Public vs Global

Access Modifiers - Private vs Protected vs Public vs Global

Types of Access Modifiers

1. Private
2. Protected
3. Public
4. Global

Modifier Who Can Access
private Only within the same class
protected Same class and any subclass (inner or outer), even in a different class
public Any Apex code within the same org
global Any org (e.g., external orgs using a Managed Package)


Accessibility level
Private < protected < Public < Global

  • Class can we either Public or Global
  • Default Access Modifier for variable and methods is private

Share