Group Discounts available for 3+ students and Corporate Clients

Sample Apex Classes

Sample APEX Classes:-

Class for Account Creation

Public Class AccountCreation
Public List<Account> CreateAccount(String s, String p){
List<Account> a = new List<Account>();
for(Account acc:a)
insert all;
return a;

Go to Developer Console and execute the following code:

AccountCreation ac= new AccountCreation();

Ac.CreateAccount(‘Osmania University’, ‘9052’);

 Example for Static Keyword

Public Class HelloWorld{
Public static void Method1(){
System.debug('Capital Info Solutions');
Public void method2(){
System.debug('Osmaina University');

Go to the Developer Console and execute the following HelloWorld hw= new HelloWorld();

Hw. Method1(); // It gives Error. For static methods we cannot have instant for the class. HelloWorld.Method1();


Inclined to build a profession as Salesforce Developer? Then here is the blog post on Salesforce Training Online.

Retrieving Account Records by passing Single field value(Phone number):

Public class FetchAccountNameFromPhone
Public Set<String> FetchAccName(String p) {  Set<String> s1= new Set<String>();
List<Account> acc=“Select id, Name From Account where phone”; for(Account a:acc)
String s;
System.debug('xxxxxxxxx' +s1); return s1;

Apex class for creating account,contact,opportunity ata a time

Public class Acc_Con_Opty_Creation
Public Account CreateAccount(String n)
Account a = new Account(); a.Name=’n’;
insert a;
Contact c = new Contact(); c.LastName='Satti Reddy';;
insert c;
Opportunity opp= new Opportunity(); opp.Name='Test Opportunity';
Date d= Date.newinstance(‘2012, 2, 17’); opp.CloseDate=d; opp.StageName='Closed Lost';;
insert opp;  return a;

Go to the Developer Console and execute the following:

Acc_Con_Opty_Creation acoc= new Acc_Con_Opty_Creation();

Acc. CreateAccount(‘capital info Solutions’);

For indepth understandingng on Salesforce click on

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at, we will update the article in 24 hours.”

0 Responses on Sample Apex Classes"

Leave a Message

Your email address will not be published. Required fields are marked *


Please Enter Your Details and Query.
Three + 6