Concepts or coding lessons of Salesforce that you can implement easily

Salesforce Interview Questions - Part 5

101. What is the difference between public cloud & private cloud in salesforce? Is salesforce.com a public cloud or private cloud?
Answer :
Public Cloud: Could services are provided "as a service" over the Internet with little or no control over the underlying technology infrastructure. More than one tenant can use the same resources.
Private Cloud: This also offers activities and functions "as a service" but is deployed over a company intranet or hosted data center. This is private product for a company or organization offering advance security.
Salesforce.com: Is a public cloud as it is hosted on salesforce.com data centers and data of more than one tenant resides on same servers.

102. What is the difference between apex:pageMessages, apex:pageMessage, apex:Message and apex:Messages?
Answer :
apex:PageMessages:

This component displays all messages that were generated for all components on the current page, presented using the salesforce styling. This will display both salesforce generated messages as well as custom messages added to the ApexPages class 

apex:PageMessage:

Apex:PageMessage is a component that adds single message on the page. This is used to display custom message using the salesforce formatting

apex:Message:

apex:Message is used to display an error on only a specific field. It is used to allow developers to place field specific errors in specific location.

apex:Messages:

apex:Messages is similar to apex:Message but it displays all errors


103. What are the aggregate functions supported by salesforce SOQL?
Answer :
Following aggregate functions are supported by salesforce SOQL
1. SUM()
2. MIN()
3. MAX()
4. COUNT()
5. AVG()
6. COUNT_DISTINCT()

104. Write a sample aggregate query or explain how to write a aggregate queries?
Answer :
The return types of Aggregate functions are always an array of AggregateResult.

Sample Code

AggregateResult[] ar = [select AVG(Amount) aver from Opportunity];
Object avgAmt = ar[0].get('aver’);

105. Write a code to find the average Amount for all your opportunities by campaign?
Answer :
AggregateResult[] arList = [select CampaignId, AVG(amount) from Opportunity group by CampaignId];
for(AggregateResult ar : arList){
    System.debug('CampaignId ' + ar.get('CampaignId'));
    System.debug('Average Amount' + ar.get('expr0'));
}



106. What are groups in SFDC and what is their use in salesforce?
Answer :
Groups are set of users. They can contain individual users, other groups, the users in a particular role or territory, or the users in a particular role or territory plus all of the users below that role or territory in the hierarchy.
There are two types of groups:
•  Public groups: Only administrators can create public groups. They can be used by everyone in the organization.
•  Personal groups: Each user can create groups for their personal use.
You can use groups in the following ways:
•  To set up default sharing access via a sharing rule
•  To share your records with other users
•  To specify that you want to synchronize contacts owned by others users
•  To add multiple users to a Salesforce CRM Content library
•  To assign users to specific actions in Salesforce Knowledge

107. Write a syntax and structure of scheduler class?
Answer :
Sample class

global class ScheduleDemo implements Schedulable{
    global void execute(SchedulableContext sc){
        BatchClass b = new BatchClass();
        database.executeBatch(b);
}
}

108 .How to schedule export or take the backup of salesforce?
Answer :
Step by Step Instruction:

  • Click Setup >Data Management > Data Export > Schedule Export.
  • Select the desired encoding for your export file. Leaving the default is fine.
  • Check the Include in export checkbox if you want to include attachments in the export (optional)
  • Leave the default Replace carriage returns with spaces if you want your export files to have spaces instead of carriage returns.
  • Select Weekly as the frequency for the exports.
  • Choose start and end dates. Set the end date to sometime in the distant future such as 20 years from the begin date.
  • Set the time of day for your scheduled export. The export is put in a job queue and the exact time of the export will depend on the amount of activity in the queue.
  • You can select the types of data to include in your export. It is best to include all data in your export file. This will make sure all your organizations data is exported.
  • Click Save.

Points to Remember:

  • Formula and roll-up summary fields are never included in exports.
  • Articles are not included from exports.
  • The export notification email is sent to the email address on file for the user who created the scheduled export. There is no way to indicate another email address. If as an Administrator you want the email to go to another person, have them grant you login access, login as them and schedule the data export.
  • Important:
  • Scheduled backup exports of your data are limited to weekly exports.
  • You have 48 hours from the time you are notified the backup is available to download the backup file.
  • The email notification for backups goes to the email address in Salesforce of the person logged in who schedules the backup.


109. How to import attachments using Data Loader in salesforce?
Answer :
Please follow the instructions below.

1. Create an AttachmentList.csv file with the following column headers:
• ParentId - ID of the record to which the attachment should be associated 
• Name - Name of the attachment 
• ContentType - Format of the extension (e.g. .xls, .pdf, etc) 
• OwnerID - ID for the owner of the attachment
• Body - File path to the Attachment on your local machine (C:\Attachments\YourAttachmentFileName.pdf)
2. Log in to the Data Loader. 
3. Select the "Insert" command. 
4. In the 'Select Sforce Object' step, select the 'Attachments’ object. This object is not displayed by default hence check the 'Show all Sforce Objects' checkbox. 
5. Choose the AttachmentList.csv file. 
6. In the mapping step, map the following fields:
• Parent ID 
• Name 
• Owner ID 
• Body - Make sure to map the Body column which you created previously with the file extension. This is how you designate the file and location of the attachments to be inserted. 
7. Click "OK" to start the upload.

110. What is the difference between custom controller and extension in salesforce?
Answer :
Custom Controller: A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.
Controller extension: A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:
• You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
• You want to add new actions.
• You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.
A controller extension is any Apex class containing a constructor that takes a single argument of type ApexPages.StandardController or CustomControllerName, whereCustomControllerName is the name of a custom controller you want to extend.
Note: Although custom controllers and controller extension classes execute in system mode and thereby ignore user permissions and field-level security, you can choose whether they respect a user's organization-wide defaults, role hierarchy, and sharing rules by using the with sharing keywords in the class definition.


111. Difference between with sharing and without sharing in salesforce ?
Answer :
By default, all Apex executes under the System user, ignoring all CRUD, field-level, and row-level security (that is always executes using the full permissions of the current user).
without sharing:
Enforcing the User’s Permissions, Sharing rules and field-level security should apply to the current user.
For example:
public with sharing class sharingClass {
// your Code here
}
without sharing:
Not enforced the User’s Permissions, Sharing rules and field-level security.
For example:
public without sharing class noSharing {
// your Code here
}
Enforcing the current user’s sharing rules can impact: (with sharing)
SOQL and SOSL queries – A query may return fewer rows than it would operating in system context.
DML operations – An operation may fail because the current user doesn’t have the correct permissions. For example, if the user specifies a foreign key value that exists in the organization, but which the current user does not have access to.

112. What are email services in salesforce and explain how we can use them in code?
Answer :
Email services are automated processes that use apex class to process the contents, headers and attachment of an inbound email.

Sample code

Use Case: create a contact record if the inbound email subject is Create Contact and body contains contact name

global CreateContactFromEmail implements Messaging.InboundEmailHandler{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelop envelop){
    Messaging.InboundEmailResult res = new Messaging.InboundEmailResult();
    String strToCompare = 'Create Contact’;
    If(email.subject.equalsIgnoreCase(strToCompare)){
        Contact c = new Contact();
        c.LastName = email.plainTextBody();
        insert c;
        
        //save text attachments

for(Messaging.InboundEmail.TextAttachment att : email.textAttachments){
    Attachment a = new Attachment();
    a.Name = att.fileName;
    a.Body = att.Blob.valueOf(att.Body);
    a.ParentId = c.Id;
    insert attachment;
}
        
//save binary attachments

for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
            Attachment attachment = new Attachment();
            attachment.Name = bAttachment.fileName;
            attachment.Body = bAttachment.body;
            attachment.ParentId = c.Id;
            insert attachment;
}
}
res.Success = true;
return res;
}
}

113. What is Wrapper Class in Apex Salesforce ?
Answer :
Wrapper class is collections of different data type, subject etc.

In following example  we are  bind Account ,Opportunity standard object. We query and perform

business logic on the Collection of elements across unrelated objects with the custom data type.


Visual Force Page:

<apex:page controller="wrapperDemoCtrl">

<apex:pageBlock title="Account From wrapper  Class">

   <apex:pageBlockTable value="{!wraccount}" var="wra">

   <apex:column value="{!wra.acc.Name}"/>

   </apex:pageBlockTable>

</apex:pageBlock>

<apex:pageBlock title="Opportunity From wrapper  Class">

   <apex:pageBlockTable value="{!wraoppn}" var="wropp">

   <apex:column value="{!wropp.op.Name}"/>

   </apex:pageBlockTable>

</apex:pageBlock>


</apex:page>

Apex Controller :

public class wrapperDemoCtrl {

    public list<wrapperClass> wraplist{get;set;}
  
    public list<wrapperClass> getwraccount()
          {
            list<Account>acclist=[select Id,Name from Account limit 3];
            wraplist= new list<wrapperClass>();
            for(Account acn: acclist)
            {
            wraplist.add(new wrapperClass(acn));
            }
           return wraplist;
          }
    public list<wrapperClass> getwraoppn()
        {
         list<Opportunity>opplist=[select Id,Name from Opportunity limit 3];
         wraplist= new list<wrapperClass>();
         for(Opportunity opn:opplist )
         {
         wraplist.add(new wrapperClass(opn));
         }
         return wraplist;
        }
  
    public class wrapperClass{
  
        public Account acc {get;set;}
        public Opportunity op {get;set;}
      
        public wrapperClass(Account accn){
      
                 acc= accn;         
                     }
       public wrapperClass(Opportunity opn)
       {
         op=opn;
      
       }
    }
}

114. How can we hard delete a record using a Apex class/by code?
Answer :
ALL ROWS key word can be used to get all the records including records in the recycle bin.
Below is the sample code to delete contact records from recycle bin
List<Contact> dContactList=[Select ID From Contact Where IsDeleted = true limit 199 ALL ROWS];
Database.emptyRecycleBin( dContactList );

How do you do File Upload using visualforce?
Answer :
Below is the code sample of file upload in visualforce
<!-- Upload a file and put it in your personal documents folder-->
<!-- Page: -->
<apex:page standardController="Document" extensions="documentExt">
<apex:messages />
<apex:form id="theForm">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:inputFile value="{!document.body}" filename="{!document.name}"/>
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
/*** Controller ***/
public class documentExt {
public documentExt(ApexPages.StandardController controller) {
        Document d = (Document) controller.getRecord();
        d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents
    }                
}

115. Explain Class Constructors with example?
Answer :
• A constructor is a special method used to create (or instantiate) an object out of a class definition.
• Constructors never have explicit return types.
• Constructors have the same name as the class.
• Classes have default, no-argument, public constructor if no explicit constructors is defined.
• If you create a constructor that takes arguments and still want a no-argument constructor, you must explicitly define one.
• Constructors can be overloaded, meaning you can have multiple constructors with different parameters, unique argument lists, or signatures.
• Constructors are called before all other methods in the class.
For Example:
public class TestObject2 {
private static final Integer DEFAULT_SIZE = 10;
Integer size;
//Constructor with no arguments
public TestObject2() {
this(DEFAULT_SIZE); // Using this(…) calls the one argument constructor
}
// Constructor with one argument
public TestObject2(Integer ObjectSize) {
size = ObjectSize;
}
}
New objects of this type can be instantiated with the following code:
TestObject2 myObject1 = new TestObject2(20);
TestObject2 myObject2 = new TestObject2();


116. What are the available Trigger Events?
Answer :
There are 6 trigger events available.
1. Insert
2. Update
3. Delete
4. Merge
5. Upsert
6. Undelete

117. What are the available Trigger contest variables?
Answer :
Below are the list of Trigger context variables
1. isBefore
2. IsAfter
3. isInsert
4. IsUpdate
5. isDelete
6. isUndelete
7. isExecuting
8. new
9. old
10. newMap
11. oldMap
12. size

118. Let’s say we have to update the same record in After Trigger context. Is there any way or workaround?
Answer :
If we create a new instance of a sObject in the Apex Trigger in memory using the Id of the newly created record as provided in the After Trigger context, we can perform an Update DML statement and not get a read only error. This is because in Apex, the SObject is seen as a new reference (even though the records have the same SFDC ID) and therefore is eligible for DML operations. The below snippet of code illustrated this working and not working.
List<Contact> originals = new List<Contact>();
if(mirrorResultMap.values().size() > 0)
{
    for(Contact origContact : contactRecs.values())
    {
        Contact mirrorContact = mirrorResultMap.get(origContact.Id);
        //origContact.Linked_Contact__c = mirrorContact.Id; //Link the Original Record i.e. Mirror Record WILL FAIL
        Contact origContactUpdate = new Contact(Id=origContact.Id, Linked_Contact__c = mirrorContact.Id); //This will WORK
        originals.add(origContactUpdate);
    }
    //update contactRecs.values(); //Update the Records -> THIS WILL FAIL AS ITS ORIGINAL RECORDS IN MEMORY
    update originals;
}

119. How to get the picklist value in Apex class?
Answer :
Using Dynamic apex, we can achieve this. On object of type pickilist, call getDescribe(). Then call the getPicklistValues() method. Iterate over result and create a list. Bind it to <apex:selectOptions>.
Code Example:
Let’s say we have a custom object called OfficeLocation__c. This object contains a picklist field Country__c.
The first thing we need to do, within our controller is use the getDescribe() method to obtain information on
the Country__c field:
Schema.DescribeFieldResult fieldResult = OfficeLocation__c.Country__c.getDEscribe();
We know that Country__c is a picklist, so we want to retrieve the picklist values:
List<Schema.PicklistEntry> ple = fieldResult.gerPicklistValues();
The only thing left for us to do is map the picklist values into an <apex:selectOptions> tag can use for display. Here is the entire method from our controller to do this:
public List<SelectOption> getCountries()
{
  List<SelectOption> options = new List<SelectOption>();
        
   Schema.DescribeFieldResult fieldResult =
 OfficeLocation__c.Country__c.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}
With our controller logic all complete, we can call the getCountries() method from our Visualforce page,  and populate the <apex:selectList> tag:
<apex:selectList id="countries" value="{!Office_Location__c.Country__c}"
         size="1" required="true">
  <apex:selectOptions value="{!countries}"/>
</apex:selectList>

120. What are the Salesforce annotations ?
Answer :
Apex annotations modify the way a method or class is used.
Below is the list of annotations supported by salesforce :
@Deprecated:
            Use the deprecated annotation to identify methods, classes, exceptions, enums, interfaces, or variables that can no longer be referenced in subsequent releases of the managed package in which they reside. This is useful when you are re-factoring code in managed packages as the requirements evolve. New subscribers cannot see the deprecated elements, while the elements continue to function for existing subscribers and API integrations.
@Future:
            Use the future annotation to identify methods that are executed asynchronously. When you specify future, the method executes when Salesforce has available resources.
            To test methods defined with the future annotation, call the class containing the method in a startTest, stopTest code block. All asynchronous calls made after the startTest method are collected by the system. When stopTest is executed, all asynchronous processes are run synchronously.
@IsTest:           
            Use the isTest annotation to define classes or individual methods that only contain code used for testing your application. The isTest annotation is similar to creating methods declared as testMethod.
@ReadOnly:           
            The @ReadOnly annotation allows you to perform unrestricted queries against the Force.com database. All other limits still apply. It's important to note that this annotation, while removing the limit of the number of returned rows for a request, blocks you from performing the following operations within the request: DML operations, calls to System.schedule, calls to methods annotated with @future, and sending emails.

@RemoteAction:           
            The RemoteAction annotation provides support for Apex methods used in Visualforce to be called via JavaScript. This process is often referred to as JavaScript remoting.

@TestVisible:           
            Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only.

Apex REST annotations:

@RestResource(urlMapping='/yourUrl'):
            The @RestResource annotation is used at the class level and enables you to expose an Apex class as a REST resource.
@HttpDelete:
            The @HttpDelete annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP DELETE request is sent, and deletes the specified resource.
@HttpGet:
            The @HttpGet annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP GET request is sent, and returns the specified resource.
@HttpPatch:
            The @HttpPatch annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP PATCH request is sent, and updates the specified resource.
@HttpPost:
            The @HttpPost annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP POST request is sent, and creates a new resource.
@HttpPut:
            The @HttpPut annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP PUT request is sent, and creates or updates the specified resource.

More Salesforce Interview Questions and Answers:

Salesforce Interview Questions - Part 4

81. How to get the debug log of Connection user in salesforce to salesforce Integration?
Answer
When configuring Debug Logs, you cannot choose a Salesforce to Salesforce Connection User from the User Lookup, but there is a workaround to achieve this.

To begin capturing Debug Logs for a Connection User open the following URL in your browser:
https://YOURSALESFORCEINSTANCE.salesforce.com/p/setup/layout/AddApexDebugLogUser?retURL=%2Fsetup%2Fui%2FlistApexTraces.apexp&UserLookupInput_lkid=YYYYYYYYYYYYYY
&UserLookupInput=Connection%20User
Replace YOURSALESFORCEINSTANCE with your salesforce instance, UserLookupInput_lkid is the ID of the Connection User and UserLookupInput is the User name. You can find the user ID of the connection user, by inspecting the CreatedById for a record created by this user. (eg. via eclipse or Force.com explorer)

82. What are different user licenses available in salesforce and explain them?
Answer : Below is the list of licenses available in salesforce
1)     Salesforce : Full access to salesforce CRM and appExchange
2)     Salesforce Platform : Access only to Custom apps but not standard CRM
3)     Force.com One App : Designed to access only one custom app with unlimited number of tabs
4)     Force.com Knowledge Subscription : Grant user access to Force.com Light app or Force.com enterprise app but no CRM functionality
5)     Knowledge Only User :Designed for users who only need access to the Salesforce Knowledge app
6)     Chatter Free : User has access to chatter which includes feeds, profiles, files and groups 
7)     Chatter External : Designed to allow customers in Chatter groups. Customers are users outside of a company’s email domain.
8)     Chatter Only : User has access to Groups, feeds, people, profiles and files along with access to view accounts and contacts, modify custom objects and use CRM contents, Ideas.

83. What is the difference between Customer portal and Partner portal?
Answer : Traditionally Partner Portal is part of companies Partner Channel Sales efforts. It is a portal focused more on Sales force automation and the efforts of those partners that sell your products to nurture the leads you pass to them, the leads they enter in themselves and the convert to Opportunity and subsequent sale.

Customer Portal on the other hand is more focused on the Service and Support of one’s Customers.

The feature differences are that Partner Portal exposes the Leads and Opportunity objects whereas the Customer Portal does not. However, only the top tier of Partner licensing (Gold Partner licenses) exposes the Case object whereas this is standard in the Customer Portal.

84. What is a Solution in Salesforce?
Answer 
• An answer to a common question or problem
• Enables Customer Support users get up to speed quickly
• Enables Support teams to answer questions quickly and consistently
• Customers search for and browse published Solutions to self assist
• Content-Rich Solutions are an enhancement to the Solution Object which allows solution writers to integrate rich text and
images into their solutions to completely solve a problem

85. Explain Lead conversion?
Answer 
Lead can be converted in salesforce.com and the converted information is mapped to the appropriate business objects – Account, Contact or Opportunity

• The system automatically maps standard lead fields to standard account, contact, and opportunity fields
• For custom lead fields, your administrator can specify how they map to custom account, contact, and opportunity fields
• The system assigns the default picklist values for the account, contact, and opportunity when mapping any standard lead picklist fields that are blank. If your organization uses record types, blank values are replaced with the default picklist values of the new record owner.
• If the lead has a record type, the default record type of the new owner is assigned to records created during lead conversion.

86. Explain the lead conversion process in salesforce?
Answer : When you convert a lead, the standard lead fields are automatically converted to the new account, contact, and, optionally, an opportunity using the information from the lead.
Custom lead fields are converted to custom account, contact, and opportunity fields as specified by your administrator.
All open and closed activities from the lead are attached to the account, contact, and opportunity.


87. What are differences between workflows and approval process?
Answer 
The key difference between workflows and approval process are as below
Workflow rules consist of single step and a single action where as approval process has multiple steps and different actions.
Workflow rules trigger automatically and the rules when triggered are not visible to the user. Approval process on the other hand, contains multiple step s each requiring a specific "I Approve or Reject" user action by the specified approvers.


88. Tell me about Jump Start Wizard versus Standard Wizard in Salesforce?
Answer 
The Jump Start wizard creates a one-step approval process for you in just a few minutes
The Standard Wizard is useful for complex approval processes.

Jump Start Wizard
• The jump start wizard is useful for simple approval processes with a single step.
• Use the jump start wizard if you want to create an approval process quickly by allowing Salesforce to automatically choose some default options for you.

Standard Wizard
• The standard wizard is useful for complex approval processes.
• Use it when you want to fine tune the steps in your approval process.
• The standard wizard consists of a setup wizard that allows you to define your process and another setup wizard that allows you to define each step in the process.

89. What is the Parallel Approval Routing ?
Answer :
Parallel Approval Routing is sending approval requests to multiple approvers in a single step Wait for approval from all the approvers or wait for approval from any one
Configure an approval step to request approval from any combination of multiple users and related users
Configure 25 parallel approvers at each step.

90. What are the Time-Dependent Workflow – Considerations ?
Answer :
Maximum of 10 time triggers per rule
Maximum of 40 actions (10 x 4 types) per time trigger, and 80 actions per workflow rule
Workflow default user must be set up before creating time-based rules
Precision limited to hours or days
Cannot convert leads with time-dependent actions in the Workflow Queue
Time triggers cannot be added to or removed from activated workflow rules
Not possible to create a time-dependent action associated to a rule with a trigger type of Every time the record is created or updated

91. What are the Time-Dependent Workflow Limitations ?
Answer :
Time triggers don’t support minutes or seconds.
Time triggers can’t reference the following:
•  DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW.
•  Formula fields that include related-object merge fields.

You can’t add or remove time triggers if:
•  The workflow rule is active.
•  The workflow rule is deactivated but has pending actions in the queue.
•  The workflow rule evaluation criteria are set to Evaluate the rule when a record is: created, and every time it’s edited.
•  The workflow rule is included in a package

92. We have a Time Based Workflow and there is Action scheduled to be executed. If we Deactivate the workflow, Scheduled actions will be removed from queue or not?
Answer :
Even after deactivation of workflow, its action will be active in queue.

93. We have Time Based Workflow and there is action scheduled to be executed. Can we delete that workflow?
Answer : If a workflow has any pending time dependent action, then we cannot delete the workflow.

94. How to clear the Time based workflow action queue?
Answer 
Two ways to achieve this: 
1. Make criteria false for all those records. 
2. Navigate to Set up -> Monitoring -> Time Based Workflow, search for scheduled actions and remove from queue.

95. When the Add Time Trigger button is unavailable?
Answer :
The evaluation criteria are set to Evaluate the rule when a record is: created, and every time it’s edited.
The rule is activated.
The rule is deactivated but has pending actions in the workflow queue.

96. In salesforce which fields are indexed automatically?
Answer :
The following fields are indexed by default:
•  primary keys (Id, Name and Owner fields),
•  foreign keys (lookup or master-detail relationship fields),
•  audit dates (such as LastModifiedDate),
•  Custom fields marked as External ID or Unique

97. What is a Category in Salesforce ?
Answer :
• Mechanism to organise Solutions
• Solutions may be associated to one or more Categories
• Categories make up a Solution Category tree structure
What are Suggested Solutions?
• The suggested solutions feature displays up to ten relevant solutions that may help users and customers solve a particular case from the case detail page and the Self-Service portal.
• Suggested Solutions can be enabled for the following:
Cases tab
Self Service Portal
Case auto-response rules and emails.

98. What are different Organization Wide Defaults? Explain each of them?
Answer :
Below are the different OWD values :
Private
    If the OWD for an object is set to private, then only the owner, and users above that role in role hierarchy, can view, edit and report on those records
Public Read Only :
    If the OWD for an object is set to Public Read Only, then all users can view and report on records but they cannot edit them. Only the record owner and the users above that role in the role hierarchy can edit the records
Public Read/Write :
If the OWD for an object is set to Public Read/Write, then all users can view, edit and report on all records. But only owner of the record can delete the records.

Public Read/Write/Transfer :
This is available only for Case and Lead objects
If the OWD for an object is set to Public Read/Write/Transfer then, all users can view, edit, Transfer and report on all the records but only owner of the record can delete the records

Public Full Access :
This is available only for Campaign object.
If the OWD for Campaigns are set Public Full Access then, all users can view, edit, delete and report on all records.

No Access, View Only or Use :
This is available only for Price Book object.
If the OWD for Price Book is set Use then, all users can access the Price Book information and as well as using the Price Book configuration for Opportunities with Products.
If the OWD for Price Book is set View Only then, all users can access the Price Book information but not to use that Price Book detail in Opportunities with Products
If the OWD for Price Book is set No Access then, it restricts users from accessing information for Price Book and Prices.

Controlled By Parent :
If the OWD for any object is set as Controlled By Parent, then user can perform an action on the record based on whether they can do the same on the parent record associated with it.

99. What are differences between custom settings and custom objects?
Answer :
Custom Settings:
1. Custom settings are SOQL inexpensive
2. We can’t write triggers on custom settings
3. Fields on which we can create custom settings are restricted like picklists, lookups and formula fields can’t be created in custom settings
4. No Page layouts, record types, validation rules and workflow rules can be used on custom settings.
5. Custom Settings SOQL is faster than custom objects.

Custom Objects:
1. Custom Objects are SOQL Expensive
2. We can have triggers on custom objects
3. No restrictions on creation of fields
4. Can be used on Custom objects
5. Custom objects SOQL not fast as a custom Settings . 

100. How to get all the required fields of sObject dynamically?
Answer :
There is no direct property available in Apex dynamic API to represent the required field. However there is another way to know about it.
If any fields have below three properties then it is mandatory field.
1. If it is Creatable
2. If it is not nillable and
3. If it does not have any default value

Map<String, Schema.SObjectType> m  = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get(so.apiName) ; // Like Account object
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
for(String f : fields.keyset())
{
    Schema.DescribeFieldResult desribeResult = fields.get(f).getDescribe();
    if( desribeResult.isCreateable()  && !desribeResult.isNillable() && !desribeResult.isDefaultedOnCreate() )
    {
//This is mandatory / required field
    }
}


More Salesforce Interview Questions and Answers: