Salesforce Interview Questions with Answers:

In this blog post, I will be presenting some common Salesforce Interview questions asked by employers in the past couple of years. I have also tried to cover some real-time questions as well.
Below is the list of common Salesforce interview questions:

 

Question 1: A custom object contains some records, now my requirement is to create field in this object with master detail relationship. Can we create master detail relationship in this case?
You can not create a Master detail relationship on a object if it already has records in it. You need to follow below steps to create a Master Detail Relationship:
Step 1: Create a Lookup relationship first.
step 2: Populate the value for the parent object in all the records.
Step 3: Change the field type from Lookup relationship to Master detail.

Question 2: What is difference between Role and Profile?
Profile controls the visibility of the application. It controls what object and fields are visible to the user but profile doesn’t control what records are visible to the user. Role controls the record level access whereas Profile define the object level access.You can not create a user without assigning a profile to the user but you can create a user without assigning a role.

Question 3: What are sandboxes and different types of sandbox?
Sandboxes contain the copy of your production data. You cannot directly make changes to the production environment. In order to make any changes, you need to first test the changes on the sandboxe like a developer sandbox or a QA sandbox and then if everything looks good, you can deploy those changes to production. Sandbox is the environment used for testing and developing application.

Types of Sandboxes:
1. Developer sandbox
2. Developer Pro sandbox
3. Partial copy sandbox
4. Full sandbox

Question 4: How can you get more than 50,000 records in trigger?

If I have more than 50000 items(custom object) in salesforce.And If I want to retrieve 50000 records using the below query :

List<Item__c> itm_list = [Select id, item_name__c from Item__c];

This query will result in governor limit exception, because the maximum number of records that can be fetched by a SOQL query is 50000. So in order to resolve this issue, you can use batch apex in which you can process the records in form of batches and each batch can have records under the governor limit standards. For e.g. if you have 1000 records to process, in that case you can divide these records in 5 batches and each batch will have 200 records. Similarly you can divide 50000+ records in the form of batches and process the each batch separately. Default batch size is 200 records.

Question 5: Can we call @future method in Batch apex?
@Future method can not be called from a batch class but a webservice can call the @Future method. So from your batch class, you can call an Apex webservice and that webservice can than call the @future method. So this is the work around to call the @future method from a Batch Apex.

Question 6: What is the difference between actionFunction , actionSupport, actionRegion?

<apex:actionFunction>
This component provides support for invoking controller action methods directly from JavaScript code using an AJAX request and we can use action function from different places on visual force page.

<apex:actionSupport>
<apex:actionSupport/> Invoke the controller method using AJAX when event occurs on page like onMouseOver, onClick, etc. and we can use action support for particular single apex component.

<apex:actionRegion>An area of a Visualforce page that demarcates which components should be processed by the Force.com server when an AJAX request is made. Only the components in the body of the <apex:actionRegion> are processed by the server, thereby increasing the performance of the page.

Question 7: What is stateless and stateful in Batch apex?
Batch Apex is stateless by default. That means for each execution of your execute method, you receive a fresh copy of your object. All fields of the class are initialized, static and instance.

If your batch process needs information which needs to be shared across transactions, one approach is to make the Batch Apex class stateful by implementing the Stateful interface. By making the batch apex stateful, it instructs Force.com to preserve the values of your static and instance variables between transactions.

Question 1: Can two users have the same profile? Can two profiles be assigned to the same user?
Question 2: What are Governor Limits in Salesforce?
Question 3: What is a sandbox org? What are the different types of sandboxes in Salesforce?
Question 4: Can you edit an apex trigger/ apex class in production environment? Can you edit a Visualforce page in production environment?
Question 5:What are the different data types that a standard field record name can have?
Question 6: What is the use of writing sharing rules? Can you use sharing rules to restrict data access?
Question 7:What are the different types of email templates that can be created in Salesforce?
Question 8:What are dynamic dashboards? Can dynamic dashboards be scheduled?
Question 9:What are the different types of reports available in Salesforce? Can we mass delete reports in Salesforce?
Question 10:What are the different types of object relations in salesforce? How can you create them?
Question 11:What happens to detail record when a master record is deleted? What happens to child record when a parent record is deleted?
Question 12: Can you have a roll up summary field in case of Master-Detail relationship?
Question 13: Explain the term “Data Skew” in Salesforce.
Question 14:How to handle comma within a field while uploading using Data Loader?
Question 15: For which criteria in workflow “time dependent workflow action” cannot be created?
Question 16: How many active assignment rules can you have in a lead/ case?
Question 17: What is the difference between a Role and Profile in Salesforce?
Question 18: Why do we need to write test classes? How to identify if a class is a test class?
Question 19:What is minimum test coverage required for trigger to deploy?
Question 20: What are the different ways of deployment in Salesforce?
Question 21: What is an external ID in Salesforce? Which all field data types can be used as external IDs?
Question 22: How many callouts to external service can be made in a single Apex transaction?
Question 23: How can you expose an Apex class as a REST WebService in Salesforce?
Question 24: What is the difference between a standard controller and a custom controller?
Question 25: How can we implement pagination in Visualforce?
Question 26: How can you call a controller method from JavaScript?
Question 27: How to get the UserID of all the currently logged in users using Apex code?
Question 28: How many records can a select query return? How many records can a SOSL query return?
Question 29: What are the different types of collections in Apex? What are maps in Apex?
Question 30: How can you embed a Visualflow in a Visualforce page?
Question 31: What is the use of “@future” annotation?
Question 32: What are the different methods of batch Apex class?
Question 33: What is a Visualforce component?
Question 34: What is Trigger.new?
Question 35: What all data types can a set store?
Question 36: What is an sObject type?
Question 37: What is the difference between SOQL and SOSL?
Question 38: What is an Apex transaction?
Question 39: What is the difference between public and global class in Apex?
Question 40: What are getter methods and setter methods?

If you have a question(s) in mind which you came across in your interview. Please share with us in the comment section and I will add the question(s) to this list.

This Post Has 14 Comments

  1. I just faced some questions as follows:
    1] What is recursive in triggers?
    2] What is the best way to mention trigger ?
    3] What is work flow rules ?

  2. I heard this question from a friend who went for an interview:
    How do you edit a visualforce page?

  3. Thank you for the reply. I will add these questions to the post

  4. I just faced some questions as follows:
    1) How do you deactivate a trigger in production
    2) How you get more than 50,000 records in trigger
    3) difference between custom settings and custom Objects
    4) difference between actionFunction , actionSupport, actionRegion
    5) can we call @future method in Batch apex
    6) what is stateless and statefull in Batch apex
    7) what is viewstate
    8) how do we call in visualforce page another visualforce page
    9) difference between External ID and Unique
    10) can we insert multiple object records using Dataloader

  5. Thank you Jyothi.. These question were really helpful!!

  6. How Can I get Answers for all QuestionS? Did anyone prepared the answers?

  7. Question 1: A custom object contains some records, now my requirement is to create field in this object with master detail relationship. Can we create master detail relationship in this case?
    Answer: we can create master details relationship if the existing records are lookup is populated and linked with the parent sobjects records, otherwise error will come.

    Question 2: What is difference between Role and Profile?
    Answer: role is define as record level access.
    Profile is define as object level access.

    Question 3: What are sandboxes and different types of sandbox?
    Answer: Sandbox is the environment for the testing and developing application.
    or it is a copy (replica) of production org.
    types:
    developer
    developer pro
    partial copy
    full copy

  8. Question 1: A custom object contains some records, now my requirement is to create field in this object with master detail relationship. Can we create master detail relationship in this case?
    Ans. We can not create a Master-detailed relationship on an existing custom object if their are any records already exists. We have to delete those records in order to create master-detailed relationship.

    Question 2: What is difference between Role and Profile?
    Ans. Role controls the user’s record level access permissions through role hierarchy and sharing rules, where as the profile can be used to assign the user a specific profile(like System administrator) and it specifies the most basic access for users.

    Question 3: What are sandboxes and different types of sandbox?
    Ans. Sandboxes are duplicates or copies of your organization. The type will be determined based on your org (or what you pay for). As a Nonprofit, you get a free “developer” sandbox as part of your donation. The “developer” sandbox is a “config” only sandbox, meaning its a duplicate of your database, but without your data. Its a great way to test changes to your structure, fields or packages.

    Types of Sandboxes:
    1. Developer sandbox
    2. Developer Pro sandbox
    3. Partial copy sandbox
    4. Full sandbox

    They differ by Storage limit, Refresh interval and Org Edition.

  9. Interview Questions I have faced:
    1) How child records updated to parent record?
    A: Process builder, Triggers.
    2)In what contacts apex code is not executed in system mode?
    A: Standard controllers
    3)By using changesets can we deploy everything?
    4) What kind of applications developed using lightning?
    5) Why email alerts used in VIsual force?
    6)To what kind of apps test classes are written?
    7) What are Assignments?
    8) How to retrieve records of contacts from accounts in SOQL?
    9) syntax in visual force to display tables?
    10) In data loader how can you import null values?
    11) What are queues?
    12) What are fieldsets?

  10. Thank you Harika for these questions.

  11. As we can’t use “*” in SQOL queries in what manner can we refer multiple fields in query (suppose we have to mention more than 50000 fields) ? We just can’t manually introduce all the fields
    In what manner can this be achieved?

    1. Check Question 4 on this page : How can you get more than 50,000 records in trigger?
      If I have more than 50000 items(custom object) in salesforce.And If I want to retrieve 50000 records using the below query :
      List itm_list = [Select id, item_name__c from Item__c];
      This query will result in governor limit exception, because the maximum number of records that can be fetched by a SOQL query is 50000. So in order to resolve this issue, you can use batch apex in which you can process the records in form of batches and each batch can have records under the governor limit standards. For e.g. if you have 1000 records to process, in that case you can divide these records in 5 batches and each batch will have 200 records. Similarly you can divide 50000+ records in the form of batches and process the each batch separately. Default batch size is 200 records.
      let me if that helps !

  12. Nice post!!! This is a very nice blog Thanks for this informative post

  13. Where to get the answer of these Question?
    I have others also which is really confusing for me

Leave a Reply

Close Menu