Prepare for your next Salesforce developer interview with these top questions and expert answers. Covers Apex, Lightning, integrations, and real-world scenarios to help you succeed.
Admin (Configuration & Setup)
Q:1. When would you choose a Lookup relationship over a Master-Detail and why?
Ans: You choose a Lookup relationship over a Master-Detail relationship when you want to create a loose association between two objects, meaning:
- Optional Relationship: In a Lookup, the child record can exist without being linked to a parent, unlike Master-Detail where the parent is mandatory.
- No Cascade Deletion: Deleting the parent does not delete the child record.
- Separate Security and Ownership: The child record does not inherit the parent’s sharing settings or owner. You manage them independently
- No Roll-Up Summary: You cannot create roll-up summary fields on the parent object in a Lookup relationship.
Similarly, you can answer why you would choose a Master-Detail relationship over a Lookup by simply reversing the above points.
Q:2. What is the difference between Record Types and Page Layouts?
Ans: Record Types and Page Layouts are both used in Salesforce to control how data is displayed and entered, but they serve different purposes. Here’s how they differ
Record Types – Control Business Logic
- Allow you to create different business processes, picklist values, and record categories for the same object.
- Useful when you have different types of users or use cases for the same object (e.g., B2B vs B2C opportunities).
Page Layouts – Control User Interface
- Determine what fields, sections, buttons, and related lists users see on a record detail or edit page.
- You can assign different page layouts to different profiles through Record Types.
- Control the visual experience, not the business logic.
How They Work Together
- Record Types define the type of record, and
- Page Layouts define how that record looks to the user based on profile and record type.
Development (Apex & Triggers)
- What are the differences between Queueable and Batch Apex? Which one would you use for retry logic?
- What is the use of Database.SaveResult[] and how would you implement error handling using it?
- Explain a real-world use case where you used Custom Metadata Types in your Apex logic.
- Can we call a future method from a trigger? Why or why not?
- What are governor limits? Name a few important ones
- What are the best practices to avoid recursive triggers?
- How to handle bulk operations in triggers?
Lightning Web Components (LWC)
- How would you implement conditional rendering in LWC based on dynamic data?
- What are lifecycle hooks in LWC, and when do you use renderedCallback()?
- How would you optimize component performance when working with large datasets?
Integration (REST, Platform Events, Named Credentials)
- What is the difference between a REST callout and a Named Credential?
- Share a scenario where you handled two-way communication between Salesforce and an external system.
- Explain how to create a custom REST API in Salesforce and expose it to external systems.
Scenario-Based Questions
- A user reports that their LWC component is not updating after a DML operation – how would you troubleshoot it?
- How would you ensure data integrity when multiple users are updating the same record from different UI components?
- You need to deploy Apex changes and LWC components to production without downtime. How would you plan the deployment?