Site Loader
Get a Quote

In this tutorial, I am going to explain you about Apex Class in Salesforce.

Introduction:

A class is a blueprint or template for an object. We create an object of a class. An object is an instance of a Class. This is the basic definition of class.
Apex is a strongly–typed object-oriented programing language. The syntax of Apex is similar to Java programming language. It acts like Stored Procedure. Force.com provides a platform for compiling, storing and running Apex program. Apex programming language has a tight integration with database query and web service support.

You can learn Introduction to salesforce here. and Introduction to Lighting Component here.

Apex Class

Features of Apex Class:

  • The syntax of Apex class is very similar to Java Classes.
  • It runs on Force.com platform.
  • Apex Class allows you to write your business logic, Database trigger.
  • Apex Class has inbuilt support for unit testing creation and execution.
  • Apex code compiles on Force.com and stores in the form of Metadata in Salesforce server. End User can send Request from UI and receive the response from salesforce server.

To Declare an Apex class we need :

Access Modifiers:

We use one of the Access Modifiers such as public, global or private.

The private access modifier declares that this class is only known locally, that is, only by this section of code. This is the default access for inner classes—that is, if you don’t specify an access modifier for an inner class, it is considered private. This keyword can only be used with inner classes.
The public access modifier declares that this class is visible in your application or namespace.
The global access modifier declares that this class is known by all Apex code everywhere. All classes that contain

Optional Modifiers:

Optional Modifiers such as virtual, abstract and so on. This is optional modifiers.

class Keyword:

the class keyword followed by the name of the class. This is required

extensions and/or implementations:

Which is also optional.

The syntax for declaring Apex Class:

 private | public | global

[virtual | abstract | with sharing | without sharing]

class ClassName [implements InterfaceNameList] [extends ClassName]

{

// The body of the class

}

What does Apex provide?

  •  Inline SOQL Support.
  •  DML calls to insert, update or Delete record
  • Send and receive emails.
  • Web Service Integration.

Hope you liked this Post about Apex Class in Salesforce.

Thank You.

Post Author: TechieFlair

Leave a Reply

Your email address will not be published.