Salesforce Apex Interview Questions and Answers Pdf

1. What is the role hierarchy?
Answer: Role Hierarchy states that a higher hierarchy person can see lower hierarchy person records.

2. One company is having some branches and all branches having different departments. So, now I want to display all departments from all branches in a single visualforce page?
Answer: Using subquery we can fetch all the required data and we can display it on the VF page.

3. Will, the inner class inherits the sharing properties of an outer class?
Answer: No, Inner classes do not inherit the sharing setting from their container class.

Classes inherit this setting from a parent class when one class extends or implements another.

4. In which object workflows are stored?
Answer: Workflow

5. I have an OWD which is read-only, how all can access my data and I want to give read-write access to a particular record to them, how can I do that?
Answer:

  • All users can just Read the record.
  • Create a Sharing Rule to give Read/Write access with “Based on the criteria” Sharing Rules. 

6. In an apex invocation how many methods that we can write as future annotations?
Answer:  10

7. What is the difference between role hierarchy and sharing rules ? will both do the same permissions?
Answer:

  • Role Hierarchy states that a higher hierarchy person can see lower hierarchy person records.
  • Sharing Rule is used to extending the Role Hierarchy.

8. Where Products are added?
Answer: Product2

9. Can I have a constructor with parameters in apex?
Answer: You do not need to write a constructor for every class. If a class does not have a user-defined constructor, a default, no-argument, public constructor is used. … In Apex, a constructor can be overloaded, that is, there can be more than one constructor for a class, each having different parameters.

10. In how many ways we can invoke flows?
Answer: We can invoke flows from different ways

  • From Apex
  • From Process Builder
  • Directly from the button invocation

11. Can we create 2 opportunities while the Lead conversion?
Answer: Yes using Apex code.

12. Is there a way to setup continous integration for apex tests?
Answer: There are a couple of decent Dreamforce presentations here: Team Development: Possible, Probable, and Painless and Continuous Integration in the Cloud.

We ran into some issues with this in practice and there was no way to get true automation (i.e., set it and forget it). We were also set it up with Selenium.

Here were the issues that I remember.

Some features aren’t supported in the metadata API and cannot be moved via the ant migration. If you have any unit tests that work with those features, you have to manually work on your CI org.

Deletions are harder to maintain. You have to manually update and apply a destructiveChanges.xml file or replicate the deletion in the CI org.

We ran into a situation where some metadata XML files had ‘invalid’ data in them. The suggested solution was to build a post-checkout script that manipulates the offending XMLs into valid XML. Not ideal.

On projects, we wanted to track just our changes and push out just our changes in source control. In theory, this would allow much easier rebaselining. This would have required more manual maintenance of XML files (e.g., 2 new fields added on Account and only want to push those 2 fields not all (*) fields).

My conclusion is that it is worth doing if you can get it set up, but if you are working on shorter-term projects and don’t have a decent amount of time budgeted in for it, it probably isn’t worth setting up.

13. User1 is associated with profile “P”. If I create a permission set and assign it to User1, now will the Permission sets which we assigned overrides the existing profile “P”?
Answer:  No. The permission set is always used for extending the profile permission. It’s not used to override the Profile permissions. 

14. Can we invoke flows from apex?
Answer: Yes, We can call flows from the apex.

15. Is there is an alternative for the “ActionPoller”?
Answer: Using SetTimeout in Javascript and calling the apex method using apex: action function.

16. What are the recommended ways to refactor in Apex?
Answer:  I use the second method. After refactoring, I select the ‘src’ folder, use File Search/Replace and all the changes are made and saved to the server in one go.

17. In which object all salesforce objects are saved?
Answer: subject

18. Write a query below?
Answer:  I have 1 parent(account) and 1 child(contact), how will you get F.name, L.name from (learn salesforce online) child and email from the account when Organization name in an account is “CTS”?

SELECT Email, (SELECT F.Name, L.Name FROM Contacts) WHERE Name = ‘CTS’.

19. What is External id? primary id?
Answer:

  • The external id is unique to an external application.
  • The primary id is unique to the internal organization.

20. What are the different types of clouds in SF?
Answer:

  • Sales cloud
  • Service cloud

Note: Browse Latest  salesforce interview questions and salesforce tutorials. Here you can check Salesforce Training details and salesforce Learning videos for self learning. Contact +91 988 502 2027 for more information.

Leave a Comment

Scroll to Top