Development Questions and Answer
1. What is Salesforce Apex Programming Language?
Salesforce Apex language is a multi-purpose programming language and exists in multi-tenant
Environment.
Apex is the world's first Cloud based programming language.
Apex is an Object-Oriented programming language, which supports all principles of Object-Oriented
programming.
2. Salesforce Apex Programming Language Features.
Salesforce offers Data manipulation language (DML) with built in exception handling.
Salesforce Object Query Language (SOQL) and Salesforce Object Search language (SOSL) are used to
query and retrieve data.
Apex in Salesforce has built-in record-locking mechanism. This prevents record update conflicts.
Salesforce Apex programming language runs on multi-tenant Environment.
Apex code is stored in Metadata format.
It has syntax and variables similar to Java.
It provides unit testing and test execution with code coverage.
When we want to add web and Email services to your Application.
It is used to perform complex business processes.
When can add complex validation rules to your application.
Salesforce Apex can be used to add a custom logic on operations like saving a record.
3. How many ways to Write Apex Programming?
Salesforce provides the below ways to write the apex code.
1) Standard Navigation.
2) Developer Console.
3) Execute Anonymous Window:
4) Eclipse IDE.
4. How many ways To Execute an Apex Code?
We can execute the Apex code by using below formats.
1) By using Execute Anonymous Window
2) By using Triggers.
3) By using Visual Force Pages
4) By using Batch Apex
5) By using Schedule Programming
6) By using Email services
7) By using API / Webservices.
5. How many Datatypes are there?
Datatype describes the following features.
What type of data the variable can hold.
How much memory is required to store the data.
Datatypes
1. Primitive Datatypes:
Integer, Long, string, Decimal, Double, Boolean, Date, DateTime, ID, Blob.
2. SObject Datatypes:
Account, Contact, Lead, Opportunity, Case, Solution, Position C, Customer C, etc..
,2
6. What is Class?
A class is a Physical entity / Blue print, which contains a collection of variables, functions, procedures,
properties, Constructors, etc.
Classes are used to achieve the Encapsulation feature of OOP.
Note:
i. Class name should be always starts with a Character.
ii. Class Name should be single word.
iii. We can't define Two classes with the same name in the application.
iv. As a Best Practice, Class Name should be starts with a "Capital Letter".
v. Each class should be compiled and stored into "Meta data Repository" in Force.com
platform.
Develope
User r Fil Ne Apex
Menu Console e w Class
7. What is Object?
In-order to assign and access the class members, we need a reference called as an "Object".
Which is an instance of the class.
Note:
We can have one or more number of objects per a class.
Each object should have a unique name. (i.e. we can't define two objects with the same name.)
Each object holds the values for the class members.
Each object contains its own memory location.
8. What is Encapsulation?
Binding (or wrapping) code and data together into a single unit is known as encapsulation.
Its Provides Security. Ex: Class
9. What is Polymorphism?
When one task is performed by different ways simply it’s called as polymorphism.
we use method overloading and method overriding to achieve polymorphism.
10. What is Inheritance?
When one object acquires all the properties and behaviors of parent object known as inheritance. It
provides code reusability.
It is used to achieve runtime polymorphism.
A class which is inherited is known as Parent class, Base class or Super class.
A class which extends base class is known as Derived class or child class.
11. what is Abstraction?
Hiding internal details and showing functionality is known as abstraction.
we use abstract class and interface to achieve abstraction.
Different levels of hiding the Programming Elements (Variables and Methods)
Keywords:
private
protected
public
global
, 3
12. what is this keyword?
This keyword used to represent the current instance of the class.
13. what is Final keyword?
If you make any variable as final, you cannot change the value of final variable (It will be constant). if the
Class declared as final it can't be inherited.
Final variables can only be assigned a value once, either when we declare a variable or in initialization
code
If the implementation is perfect and does not requires any further modification then make that method is
final.
14. what is Super keyword?
The super keyword can be used by classes that are extended from virtual or abstract classes.
By using super, we can override constructors and methods from the parent class.
Best Practices for Super keyword:
Only classes that are extending from virtual or abstract classes can use super.
You can only use super in methods that are designated with the override keyword.
15. what is Virtual keyword?
The virtual definition modifier declares.
virtual keyword declares that the class allows extensions and overrides.
classes that are virtual cannot be global
16. what is Abstract keyword?
The class is declared with keyword abstract and known as abstract class.
If we don't know the implementation of method now and can implemented latter then make that method
as abstract.
The abstract definition modifier declares that this class contains abstract methods, that is, methods that
only have their signature declared and no body defined.
17. what is With Sharing keyword?
If you declare a class as with sharing, sharing rules given to the current user will be taken in to the consideration
and user can access and perform the operations based on the permissions given to him on objects to fields.
18. what is Without Sharing keyword?
If you declare a class as without sharing, then this apex class runs in system mode which means apex code has
access to all the objects and fields irrespective of current user sharing rules, field level security and Object
permissions.
19. what is Interface keyword?
An interface is like a class in which none of the methods have been implemented the method signatures
are there, but the body of each method is empty.
To use an interface, another class must implement it by providing a body for all of the methods contained
in the interface.
20. what is Extends keyword?
Defines a class that extents another class.
21. what is Implements keyword?
This keyword is used declare a class that impediments an interface.
22. what is return keyword?
This keyword returns a value from a method.
1. What is Salesforce Apex Programming Language?
Salesforce Apex language is a multi-purpose programming language and exists in multi-tenant
Environment.
Apex is the world's first Cloud based programming language.
Apex is an Object-Oriented programming language, which supports all principles of Object-Oriented
programming.
2. Salesforce Apex Programming Language Features.
Salesforce offers Data manipulation language (DML) with built in exception handling.
Salesforce Object Query Language (SOQL) and Salesforce Object Search language (SOSL) are used to
query and retrieve data.
Apex in Salesforce has built-in record-locking mechanism. This prevents record update conflicts.
Salesforce Apex programming language runs on multi-tenant Environment.
Apex code is stored in Metadata format.
It has syntax and variables similar to Java.
It provides unit testing and test execution with code coverage.
When we want to add web and Email services to your Application.
It is used to perform complex business processes.
When can add complex validation rules to your application.
Salesforce Apex can be used to add a custom logic on operations like saving a record.
3. How many ways to Write Apex Programming?
Salesforce provides the below ways to write the apex code.
1) Standard Navigation.
2) Developer Console.
3) Execute Anonymous Window:
4) Eclipse IDE.
4. How many ways To Execute an Apex Code?
We can execute the Apex code by using below formats.
1) By using Execute Anonymous Window
2) By using Triggers.
3) By using Visual Force Pages
4) By using Batch Apex
5) By using Schedule Programming
6) By using Email services
7) By using API / Webservices.
5. How many Datatypes are there?
Datatype describes the following features.
What type of data the variable can hold.
How much memory is required to store the data.
Datatypes
1. Primitive Datatypes:
Integer, Long, string, Decimal, Double, Boolean, Date, DateTime, ID, Blob.
2. SObject Datatypes:
Account, Contact, Lead, Opportunity, Case, Solution, Position C, Customer C, etc..
,2
6. What is Class?
A class is a Physical entity / Blue print, which contains a collection of variables, functions, procedures,
properties, Constructors, etc.
Classes are used to achieve the Encapsulation feature of OOP.
Note:
i. Class name should be always starts with a Character.
ii. Class Name should be single word.
iii. We can't define Two classes with the same name in the application.
iv. As a Best Practice, Class Name should be starts with a "Capital Letter".
v. Each class should be compiled and stored into "Meta data Repository" in Force.com
platform.
Develope
User r Fil Ne Apex
Menu Console e w Class
7. What is Object?
In-order to assign and access the class members, we need a reference called as an "Object".
Which is an instance of the class.
Note:
We can have one or more number of objects per a class.
Each object should have a unique name. (i.e. we can't define two objects with the same name.)
Each object holds the values for the class members.
Each object contains its own memory location.
8. What is Encapsulation?
Binding (or wrapping) code and data together into a single unit is known as encapsulation.
Its Provides Security. Ex: Class
9. What is Polymorphism?
When one task is performed by different ways simply it’s called as polymorphism.
we use method overloading and method overriding to achieve polymorphism.
10. What is Inheritance?
When one object acquires all the properties and behaviors of parent object known as inheritance. It
provides code reusability.
It is used to achieve runtime polymorphism.
A class which is inherited is known as Parent class, Base class or Super class.
A class which extends base class is known as Derived class or child class.
11. what is Abstraction?
Hiding internal details and showing functionality is known as abstraction.
we use abstract class and interface to achieve abstraction.
Different levels of hiding the Programming Elements (Variables and Methods)
Keywords:
private
protected
public
global
, 3
12. what is this keyword?
This keyword used to represent the current instance of the class.
13. what is Final keyword?
If you make any variable as final, you cannot change the value of final variable (It will be constant). if the
Class declared as final it can't be inherited.
Final variables can only be assigned a value once, either when we declare a variable or in initialization
code
If the implementation is perfect and does not requires any further modification then make that method is
final.
14. what is Super keyword?
The super keyword can be used by classes that are extended from virtual or abstract classes.
By using super, we can override constructors and methods from the parent class.
Best Practices for Super keyword:
Only classes that are extending from virtual or abstract classes can use super.
You can only use super in methods that are designated with the override keyword.
15. what is Virtual keyword?
The virtual definition modifier declares.
virtual keyword declares that the class allows extensions and overrides.
classes that are virtual cannot be global
16. what is Abstract keyword?
The class is declared with keyword abstract and known as abstract class.
If we don't know the implementation of method now and can implemented latter then make that method
as abstract.
The abstract definition modifier declares that this class contains abstract methods, that is, methods that
only have their signature declared and no body defined.
17. what is With Sharing keyword?
If you declare a class as with sharing, sharing rules given to the current user will be taken in to the consideration
and user can access and perform the operations based on the permissions given to him on objects to fields.
18. what is Without Sharing keyword?
If you declare a class as without sharing, then this apex class runs in system mode which means apex code has
access to all the objects and fields irrespective of current user sharing rules, field level security and Object
permissions.
19. what is Interface keyword?
An interface is like a class in which none of the methods have been implemented the method signatures
are there, but the body of each method is empty.
To use an interface, another class must implement it by providing a body for all of the methods contained
in the interface.
20. what is Extends keyword?
Defines a class that extents another class.
21. what is Implements keyword?
This keyword is used declare a class that impediments an interface.
22. what is return keyword?
This keyword returns a value from a method.