Exception Handling is a method in Salesforce that allows us to handle undesirable exceptions or problems in our code without interrupting the flow. Read on to learn more about salesforce’s exception handling with detailed examples.
It is a set of applications
Prototypes:
→ Return type name (list & saq of input declarations);
One basic reason why we need interface is because multiple inheritance is possible only through interfaces
→ Interfaces enforces a class to perform certain operations (actions)
→ The protocols b/w the class and interface is that the class must implement (define), all the method prototypes inside the interface
→ The actual technical reason behind creating an interface is not multiple inheritance. Its name and purpose behind interface is used by the operating system level services for the code
→ Providing OS level services to the code is done by Interface
→ Interface gives names and i/p
Syntax:
For interface
Interface name {
Prototypes
}
Class child implements name {
Features are mandatory to define the prototyped methods in the interface
}
Eg:
Global interface calc {
Void add ();
Void sub ();
}
Class opers implements calc {
Return a+b;
}
Public integer sub () {
Return a- b ;
}
}
Public class test {
Public static test method void main () {
Opers op1 = new opers ();
Op1.add (5,4);
System. debug (‘ subtraction is ‘ +sub);
}
}
Exception (fault) is an abnormal event that occurs generally after the execution of a program. It affects the normal program flow.
→It is run time error through which execution is stopped
→ Another name for run time error is exception error, there are two types of errors
→ A compile time (syntax) error occurs whenever we violate the syntax of the language
→ The only way to overcome this scenario is by changing the source code
→ In case of run time error this might occur not due to programming error but because of run time
→ Environment such as
→ Such errors also stop the execution
→ In order to overcome run time errors and to continue with the execution of the programming language a mechanism is provided known as exception handling
Checkout Salesforce Interview Questions
It stores large volumes of information, there are three types of collections in sales force
List:
A collection of similar volumes
It is also re sizable
Set:
Provides values which are unique
It is also re sizable
Map:
Collection of pairs
Every pair is associated with a key that is associated with a value
Pair →
Key → access the value –>(Can be an integer, string, id only )
Value can be any type
Syntax For List:
Template class, here we have to fix the data type at run time
Creation Of List:
Input to the list:
Remove → clear only one record from the list
Clear (); → content of the list will be cleared
↓
Removes common values of stud_names and list:
Output From The List:
There are four ways to display
1.For loop
2.While loop
3.Do- while
4.For – each
For:
For ( integer IND = 0; IND < stud_names. Size ;
IND ++)
{
System.debug(stud_names [IND]);
}
In apex, we will work only for – each loop
Syntax:
For each
For (data type var_name : collection _name)
{
System. Debug (var_name);
}
Eg:
For (string Sn: stud_names ) {
System.debug (Sn);
}
Means each string in that collection has to be displayed
Here, no need to specify starting & ending number and incrimination
Map:
Put (key, value) → for adding
Get (key) → for retrieving
List → we can work only for ‘subject’
Set → can’t work for subject this can work for primitive data types
↓
If we have an ID, we can access any record
We can undelete a data from the sales force within a span of 45 days.
SOQL:
Sales force object query language (SOQL) is used to retrieve the data by using “select” stmt
In SOQL search only for table
SOSL:
Sales force object search language (SOSL) is used to retrieve the data from the database, for this we used “find” stmt
Here to search the entire database
Select work with records (Table)
Find work with text based search across from the DB returns field only but not records
Save Point:
We’ve to set ‘save point’ to particular points and not for all
Governor limits:
Limits:
Check Out Salesforce Tutorials
Collection Program:
Public with sharing class call test 1 {
Public static test method void main () {
List < string > stud_names = new list < string > ();
Stud_names. Add (‘Ashok’);
Stud_names. Add (‘Yadav’);
Stud_names. Add (‘Buddi’);
For (string str: stud_names) {
System. Debug (‘name; ‘ +str);
}
List prog_books =new list ();
Prog_books = « ______ »;
Book_c Sb = new book_c ();
Sb.name = ‘apex prog’;
Sb.price _ c = 200;
Sb. Author_c = ‘krishna’;
Try {
Insert prog_books;
}
Catch (exception e) {
System.debug (‘exceeded limit’);
}
Prog-books = « ______ »;
For (Book_c b: prog_books){
System.debug (b. price_c);
System.debug (b. author_c);
}
}
}
Enroll for Live Instructor Led Online SALESFORCE TRAINING
Mindmajix offers different Salesforce certification training according to your desire with hands-on experience on Salesforce concepts
Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!
Name | Dates | |
---|---|---|
Salesforce Training | Aug 05 to Aug 20 | |
Salesforce Training | Aug 08 to Aug 23 | |
Salesforce Training | Aug 12 to Aug 27 | |
Salesforce Training | Aug 15 to Aug 30 |
Arogyalokesh is a Technical Content Writer and manages content creation on various IT platforms at Mindmajix. He is dedicated to creating useful and engaging content on Salesforce, Blockchain, Docker, SQL Server, Tangle, Jira, and few other technologies. Get in touch with him on LinkedIn and Twitter.
1 /15
Copyright © 2013 - 2023 MindMajix Technologies