Here are the list of most frequently asked Salesforce Developer Interview Questions and Answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level. The questions are for intermediate to somewhat advanced Salesforce Developer professionals, but even if you are just a beginner or fresher you should be able to understand the answers and explanations here we give.
Q1) A developer executes the below code below)
If(!isCorrect)[
System.debug(‘The value of x is true’);]
else if (!isCorrect)[
System.debug(‘The value of x is false’);]
else[
(‘The value of x is null’);]
How should a developer declare a variable ‘isCorrect’?
Q2) What will be result of the following code if there are 2 accounts named ‘Besant’? Account a = (SELECT Id,name FROM Account WHERE name=‘ABC’);
Query Exception will be thrown.
Q3) A developer has created two custom objects with API name ‘SalesOrder__c’ and Shipment__c to track order and shipments between two custom objects. The Shipment object has a custom field named Tracking_number__c that indicates the tracking number associated with a particular shipment. The developer is writing an Apex class in which he needs to retrieve all the sales order and the tracking numbers associated with their shipment records using a SOQL Query. What SOQL Query he/she will use?
SELECT NAME,(SELECT Tracking_Number__c from Shipment__r) from Sales_Order__c
Q4) A developer needs to get all IDs of related Accounts on all of the contact records. What collection data type should the developer use to avoid having duplicate IDs?
Q5) A custom object has a workflow rule that updates a field when a certain set of criteria is met. A ‘before update’ Apex Trigger has also been defined on the object. What will happen when a user updates a record so that it meets the criteria of the workflow rule?
The Apex trigger will be fired twice.
Q6) When Leads are created , a standard list of tasks should be created or completed. The Sales Manager is concerned that some Leads do not have associated tasks. What reporting feature could you use to create a report to find Leads that don’t have tasks associated with them?
Q7) In an organization, the ‘Lead Source’ field can have three possible values, two of which are the Company’s Websites that can generate leads and the third ‘phone enquiry’. You have received a requirement to create a Lead report that groups the leads generated from the two websites together and the leads generated from phone enquiry separately. How can this be achieved in Salesforce?
Create a bucket field and use it for grouping.
Q8) There are two approval processes defined on the opportunity object, one to approve the discount on the opportunity and the other approval process is to approve the services amount. When the record is submitted for approval , only one approval process is firing. What could be the problem?
It can be because of the following reasons)
The approval process entry criteria is the same for both approval process; The order of the approval processes is not correctly defined; Only one approval process is fired at one time.
Q9) There is a requirement to track which Heath Care Providers are related to which Hospitals. Hospitals are the type of account. Health Care Providers is a Custom Object. A Health Care Provider can be related to multiple hospitals . A Hospital can be related to multiple Heath Care Providers. How can this relationship can be achieved?
Create an addition junction object to connect the other two objects and create two master-detail relationship fields on that object.
Q10) You have a reporting requirement to display leads with open high priority tasks. What reporting feature would be used for this requirement?
Cross Filter & Sub Filter.
Q11) A developer created a visualforce page with a standard controller fro the Contact Object. How the developer can display fields from its related Account?
Using merge field syntax to traverse from child to parent i.e ”{!contact.Account.Name}”.
Q12) How can a developer access a static variable named a declared in Apex class named SalaryCalculation?
Q13) As a Salesforce Administartor , how can you ensure that a Social Security Number is recorded in the correct format?
Use a Validation rule to check the format is correct.
Q14) Rohan was told that Visualforce is a part of the MVC paradigm. What does MVC stands for?
Q15) What are some of the limitations of changing the data type of a custom field?
Developers cannot change the data type of a custom field that is referenced in a visualforce page, Apex Class, and also the option to change the data type is not available for all data types.
Q16) A developer is required to create a customized page that displays data from a web service callout. What controller could the developer use?
Q17) How does Salesforce track how a deal progresses through the Sales cycle?
Using Opportunity Stages.
Q18) A developer needs to get the Customer records with a Name that starts with ‘Ab’ What SOQL query will satisfy the requirement?
SELECT Id, Name, FROM Customer__c where Customer__c.Name LIKE ‘Ab%’.
Q19) A developer needs to initialize a numeric value of 50. What data type should developer use?
Q20) A developer has written the following code to do a SOSL search) FIND [USA]. What will be returned?
A list of lists of sObjects and their records that match the search term.
Q21) A developer needs to create a trigger that will throw an error whenever the user tries to delete a contact that is not associated to an account. What trigger event should be developer use?
Q22) What method displays a custom error message on a particular record and prevents any DML operations thereafter?
Q23) What is true regarding a future method?
Method annotated with @future can only return a void type, Method that are annotated with @future identify methods that are executed asynchronously.
Q24) What is the correct syntax of writing an Apex Trigger?
trigger TriggerName on ObjectName(trigger_events){code block;}
Q25) What is the order of defining a try-catch-finally block?
try{*code here*} catch(Exception e){*code here*} finally{*code here*s}
Q26) In an update trigger, how can a list of previous versions of the records be accessed?
By accessing the Trigger.old context variable.
Q27) A developer created a simple VF page calculate that has 2 numerical input fields and performs an arithmetic operation based on the user input. What method should developer use in order to process and calculate the input of the user in the controller?
Q28) Apex and Visualforce pages are prone to data access control issues. Which approach helps address these issues?
Use the [with sharing] keyword in the Apex Classes.
Q29) What is true regarding the mode that a custom controller runs in?
A custom controller runs in a system mode, however the [with sharing] keyword can be used to run in user mode.
Q30) How can a developer query a multi-select picklist?
Semicolon and comma characters can be used to add filters for the multi-select picklist field to the SOQL query; Picklist values can be specified with AND/OR logic.
Q31) Given the Visualforce page code below)
<apex)page controller=”MyController”>
<apex)pageBlock>
<apex)repeat value=”[!productlist]” vard=”pd”>
Product Name) [!pd.Name]
Price) [!pd.Price]
</apex)repeat>
</apex)pageBlock>
</apex)page>
The getter methodology within the controller methodology ought to be named as)
Q32) A Developer needs to write some code that will display ‘Welcome to the world of Salesforce’ if the string variable getAnswer is equal to ‘Salesforce’ No action is required if the variable is not ‘Salesforce’. What control flow statement should the developer use?
Q33) A developer needs to create a new account record with the following details)
Account Name= Sample Account
Account Number= AC12345
Account Rating=Hot
Billing Country=Australia
Which of the following options is a proper way of assigning these values in an account sObject?
Account acc=new Account(Name=’ Sample Account’,AccountNumber=’ AC12345’,Rating=’Hot’,BillingCountry=’Australia’);
insert acc;
Q34) What will be result of an unhandled exception on any DML statements?
DML statements will be rolled back
Q35) A developer needs to declare and initialize a variable as constant. How can this requirement be met?
Use the Final keyword on initialization.
Q36) There is a requirement to display the total expected revenue of opportunities associated with an Account record. How can this be achieved?
Create a roll-up summary field on the Account object using SUM on the opportunity.
Q37) A developer has a custom controller named ‘CustomController1’. What is the correct syntax for the constructor?
public CustomController1(){<code>}
Q38) Which Apex Control statements allows a developer to iterate on each element of a collection of an unknown size?
For(Type variable) listOrSet) loop
Q39) A before update trigger has performed a validation and determined that the record should not be saved. How can this be achieved with Apex code?
Use the addError() method.
Q40) Which methods can a developer use to determine if it is close to hitting the DML rows governor limit?
Limits.getLimitDMLRows();
Limits.getDMLRows();
Q41) A developer is required to create a customized page that displays data from a web service callout. What controller should developer use?
Custom and Extension controller.
Q42) A developer needs to update 10,000 Account records in an organization. What technique should developer use to avoid governor limits?
Q43) There is a requirement to display the role and profile of the current user on a Visualforce page. How can this be done?
Access via global data directly using expression syntax in the Visualforce Page. {!$User.FirstName}
Q44) A developer is creating a customized page in which the standard record detail page of an object is included. What Visualforce page component should developer use?
Q45) A developer is required to embed a website into a Visualforce Page. What Visualforce component should developer use?
Q46) How View State is used?
The View State is used to store state across multiple pages, such as in wizard.
Q47) A developer is required to override the standard new page when creating an account. How can this be done?
Override the standard page by creating a Visualforce page.
Q48) A developer would like to selectively include related list on a detail page. What component can be used for this?
Q49) A developer would like to run all unit tests. How can this be done?
Using[Run All Tests] from the Apex Classes Page; Selecting [Run All] from Developer Console.
Q50) What is the procedure for unit testing?
Create test data, call the method being tested, verify results.