Q1- What
is Apex?
Apex is an object-oriented and strongly typed computer
programming language which enables the developers to implement flow and
transaction control statements on all the Salesforce servers in collation with
calls to the APIs. It uses syntax that looks quite like that of Java and works
like the database stored processes. Apex helps the developers to implement
business logic with most of the system events, together with tab clicks,
related record updates, as well as the Visualforce pages.
Q2- How does Apex Work?
All Apex programs run entirely
On-Demand on Force.com Platform.
· First, the platform application server compiles the code into an
abstract set of instructions that can be understood by Apex runtime
interpreter.
· The compiled code is stored in metadata.
When the end-users triggers the
execution of Apex by clicking button or VisualForce page the application
servers retrieve the compiled instructions from the metadata and send them to
runtime interpreter before returning the result.
Q3- What are the ways to call the Apex class?
Below
mentioned are the ways in Salesforce to call Apex class.
·
From another class
·
From developer console
·
From JavaScript links
·
From home page components
·
By using trigger
·
From VisualForce page
Q4- What is meant by Apex transaction?
An Apex transaction represents a group of operations that are needed to be executed at once. It includes the Data Manipulation Language (DML) and is responsible for querying records. The DML operations in a transaction either success or if anything goes wrong or occurs even with a single record could result in a rollback of the entire transaction.
Q5- When should Apex be
used over Workflow rules or Process Builder?
There are various reasons why you
should use Apex over declarative automation options:
·
Workflow rules and Process Builder operations sometimes have
feature limitations that can be overcome with Apex. For example, pulling
information from an external system.
·
When dealing with certain or large sets of data, Apex can be
more efficient than declarative options due to less limitations.
Q6- What are some Apex best practices?
·
Bulkify your code
·
Avoid
SOQL Queries or DML statements inside FOR Loops
·
Avoid Hardcoding IDs
·
Use of the Limits Apex Methods to Avoid Hitting Governor Limits
·
Querying Large Data Sets
Q7- Explain Considerations for Static keyword in Apex.
·
Apex classes cannot be static.
·
Static allowed only in outer class.
·
Static variables not transferred as a part of View State.
·
Static variables and static block runs in order in which they
are written in class.
· Static variables are static only in scope of request.
Q8- What is the difference between public and global class in
Apex?
A public class is
accessible to the inside application or namespace. This isn't precisely similar
to a public modifier in Java.
Global class is visible
everywhere, in any application or namespace. Web Service must be proclaimed as
Global and which can be accessed inside Javascript as well. It resembles a
public modifier in Java.
Q9- What is difference insert() and database .insert()?
Using the insert method we can insert the records but if any error occurs in any record system will throw an error insertion fail and none of the records are inserted. If we want to execute partially success of bulk insert operation we will use database .insert.
Q10-What are the
different type of Collections you can have in Apex?
There
are three main types of collections…
·
Lists – A list is an ordered collection of elements that
are distinguished by their indices. List elements can be of any data
type—primitive types, collections, sObjects, user-defined types, and built-in
Apex types.
·
Sets – A set is an unordered collection of elements that do
not contain any duplicates. Set elements can be of any data type—primitive
types, collections, sObjects, user-defined types, and built-in Apex types.
·
Maps – A map is a collection of key-value pairs where each
unique key maps to a single value. Keys and values can be any data
type—primitive types, collections, sObjects, user-defined types, and built-in
Apex types.
Q11- Can you edit an apex
trigger/ apex class in production environment? Can you edit a Visualforce page
in production environment?
No, it is not possible to
edit apex classes and triggers directly in production environment.
It needs to be done first in
Developer edition or testing org or in Sandbox org. Then, to deploy it in
production, a user with Author Apex permission must deploy the triggers and
classes using deployment tools.
However, Visualforce pages
can be created and edited in both sandbox and in production.
Only if the page has to do something unique (different values), it would have to be developed via Sandbox.
Q12- How to get the
UserID of all the currently logged in users using Apex code?
You can get the ID’s of all the currently logged in users by using this global function: UserInfo.getUserId().
Stay tuned for more questions..!!!!
No comments:
Post a Comment