Saturday, May 18, 2019

Salesforce Interview Questions on Apex

1) What is with sharing and without sharing in Salesforce?

on the link for complete details)

2) What is wrapper class in salesforce?

Wrapper class in salesforce (Click on the link for complete details)

3) What is future methods in salesforce?

future method in salesforce (Click on the link for complete details)

4) Is it possible to call future method from Batch class or another future method?

No, we cannot call.

5) What is order of exceution in salesforce? 

Order of execution in Salesforce.(Click on the link for complete details)

6) What is custom setting in salesforce and what are its type? 


Custom setting is similar to the custom object in Salesforce, You can store some custom data inside this and can access this inside apex class avoiding the use of multiple soql queries.

1)List custom setting
2)Hierarchy custom setting

7) How to access list custom setting inside apex class? 


Let's say we have a custom setting called employee where we are storing employee name,roll number.
Let's assume we have some employee information stored in a custom setting as below.

Name                            Roll no

employeeName1          rollNo1
employeeName2          rollNo2

Syntax:

Fetching employee1 details,

Employee__c obj=new Employee__c.getvalues('employee1');

String rollNo=obj.rollNo1__c;

8) What is difference in list custom settings and hierarchy custom setting? 


List custom setting have user-independent values whereas hierarchy custom setting
lets you personalize setting for specific role and profile.

9) What are the methods available with List custom settings? 


Methods available with list custom settings are:

1)getAll();
2)getValues();

Syntax:

1) Map<Data_set_name, CustomSettingName__c> cus = CustomSettingName__c.getAll();

The getAll method returns values from all fields associated with list custom setting.

2)CustomSettingName__c cus = CustomSettingName__c.getValues(Data_set_name);

The getValues method returns values associated with a specific data set.

This method can be used with both list and hierarchy custom settings.

10) What are the methods available with Hierarchy custom settings? 


Methods available with Hierarchy custom settings are:

1)getOrgDefaults();
2)getInstance();

syntax:


1)CustomSettingName__c cus = CustomSettingName__c.getOrgDefaults();

The above method returns values from dataset at the organization level.

2)CustomSettingName__c cus = CustomSettingName__c.getInstance(Profile_ID or UserID);

The above method returns dataset values related to specific profiles.

11) What are apex code best practices?

Apex Code Best Practices(Click on the link for complete details)



12) How to call apex class from process builder in Salesforce?

Call Apex Code from a Process builder in Salesforce (Click on the link for complete details)

13) What is OWD in salesforce?

OWD in salesforce (Click on the link for complete details)

14) Is it possible to edit apex class in production?

No. we can edit in sandbox.

15) What are the collection types supported in apex?

List
Set
Map.

No comments:

Post a Comment