Access modifiers in Salesforce are used to define the visibility and accessibility of classes, methods, variables, and other components within an organization.
They are simple, basic data types that are built into the Salesforce platform and cannot be broken down into smallercomponents.
Integer: A whole number without a decimal point.
Double: A number with a decimal point or a fractional component.
Boolean: A data type that can have one of two possible values – true or false.
Date: A data type that represents a date.
Time: A data type that represents a specific time.
DateTime: A data type that represents a specific date and time.
String: A sequence of characters that can include letters, numbers, and symbols.
ID: A unique identifier for an object in Salesforce. ( 18, 15 ) 001GHJHGHE87734
Decimal: A number with a decimal point, with up to 18 digits
Non-primitive data type in Salesforce
The non-primitive data types in Salesforce include:
Object
Variables
Primitive
Name
Age
Non Primitive
Person Object
Animal Object
Map
List
Set
Apex Class
Variables
Methods
Assignment
Create variables for all the Primitive Data Types and print those with dummy values.
Classes in Salesforce
A class is nothing but it is a collection of objects and carries all the properties of an object.
We can also say that the class is the blueprint for creating the Objects.
A class can contains the followings –
Classes
Access Modifiers
Variable
Methods
Constructors
Access Modifiers in Salesforce
Access modifiers in Salesforce are used to define the visibility and accessibility of classes, methods, variables, and other components within an organization.
There are three types of access modifiers in Salesforce:
Public: Components with the public access modifier are visible and accessible to all classes and triggers in an organization. This means that any class or trigger in the organization can access and use these components.
Private: Components with the private access modifier are only visible and accessible within the same class in which they are defined. This means that no other class or trigger in the organization can access or use these components.
Protected: Components with the protected access modifier are visible and accessible within the same class and any subclasses that extend the original class. This means that any class that inherits from the original class can access and use these components.
Class A (Parent)
Protected Variables
Class B (Child ) extend Class A (Variable & Methods)
Access Protected Variables
Global
Managed Package ( Application ) ~= Applications in Google/Apple Store
Class
Variable
Method
Variables(States) in Salesforce
Variables in Salesforce are used to store and manipulate data within Apex code.
Hands-On Code
Assignment
Play around with Class & Instance Variable along with Access Modifiers
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion