Table of Contents
Previous Sessions
If you missed the previous sessions, please use the below links for the previous sessions
- https://www.pantherschools.com/introduction-to-oops-using-salesforce
- https://www.pantherschools.com/data-types-class-access-modifiers-in-salesforce
Methods(Behaviours) in Salesforce
In Salesforce, a method is a block of code that performs a specific task or action. Methods can be used to perform calculations, manipulate data, and interact with the Salesforce platform, such as by creating, updating, or deleting records.
Types of Methods in Salesforce
There are two types of methods in Salesforce:
- Instance/Object Methods: Instance methods are associated with an instance(Object) of a class, and can be called on that instance.
- Static(Class) Methods: Static methods are not associated with an instance of a class, and can be called on the class itself. Static methods are used to perform actions that do not require an instance of the class.
Constants
In Salesforce, you can define constants using the “final” keyword in Apex code. Constants are variables whose values cannot be changed once they are initialized.
Hands-On Code
Assignment
- Create an Instance method sum method with different parameters. Note: – Please use the return statement accordingly
- sum(1,2)
- sum(3,4,6)
- sum(3,4,6,4)
- sum(3,4,6,5,6)
- sum(3,4,6,7,8,8)
- sum(3,4,6…)
- sum(3,4,6..)
- sum(3,4,6)
- sum(3,4,6)
- sum(3,4,6)
- sum(3,4,6)
- sum(3,4,6)
- Create Class/Static methods for multiple/sub/div.
- Sub() – 2, 3, 4, 5, ——- up to
- mul() – 2, 3,4 ——
- div(23, 45)
- module() – 29/25 ~= 4
