Cognizant Salesforce interview questions
Core platform, Apex, LWC and scenario questions reported from recent Cognizant rounds, with simple answers and common mistakes.
Cognizant's Salesforce interviews for two to three years of experience test core platform knowledge first, then Apex and LWC, then scenarios. Candidates say the scenario questions decide the result, so practise explaining your approach out loud.
These are questions candidates report from recent interviews, collected from interview write-ups and rewritten with our own answers. Companies do not publish official lists and every team differs, so practise the style of question rather than memorising answers.
Each answer follows the pattern interviewers reward: what they are really checking, a clear answer in your own words with a real example, and the common mistake that loses marks.
Core Salesforce round
01What is the difference between a role and a profile?
What is the difference between a role and a profile?
What the interviewer is checking: Clear separation between what you can do and which records you can see.
A profile (with permission sets) controls what a user can do: which objects and fields they can access and which actions they can take. A role controls which records they can see, through the role hierarchy: managers see their team's records. Every user needs a profile; a role is optional but needed for record access through the hierarchy.
Today Salesforce recommends keeping profiles minimal and giving access through permission sets and permission set groups.
Common mistake: Saying profiles control record visibility.
03Explain the order of execution when a record is saved.
Explain the order of execution when a record is saved.
What the interviewer is checking: Whether you can use the order to debug a real problem.
In short: system validation, before-save flows, before triggers, custom validation rules and duplicate rules, the record is saved (not yet committed), after triggers, assignment, auto-response and escalation rules, after-save flows, entitlement rules, roll-up summary and cross-object updates on parents (which run their own save process), then the commit, and finally post-commit work such as emails and async jobs.
The point interviewers want: before-save flows run before before triggers, and validation rules run after before triggers, so a trigger can set a field that a validation rule then checks.
Common mistake: Reciting a long list but not knowing where flows and validation rules fit.
04What is the difference between insert and Database.insert?
What is the difference between insert and Database.insert?
What the interviewer is checking: That you know partial success and how to read the results.
insert records; is all or nothing: if one record fails, an exception is thrown and none are saved. Database.insert(records, false) allows partial success: valid records are saved and you get a SaveResult for each record, showing which failed and why. Use the second form for data loads and integrations where a few bad rows should not stop the rest.
Common mistake: Using allOrNone false and then ignoring the SaveResult list, so failures are silent.
Apex and LWC round
05What do Trigger.new and Trigger.oldMap hold, and when can you use them?
What do Trigger.new and Trigger.oldMap hold, and when can you use them?
What the interviewer is checking: Context variables, and which ones exist in which event.
Trigger.new: the new versions of the records, in insert, update and undelete triggers; editable only in before triggers. Trigger.oldMap: a map of Id to the previous version, in update and delete triggers. Compare the two to act only when a field changed.
Common mistake: Using Trigger.oldMap in an insert trigger, where it is null.
06What is the difference between @api, @track and @wire in LWC?
What is the difference between @api, @track and @wire in LWC?
What the interviewer is checking: Whether your knowledge of @track is current.
@api makes a property or method public, so a parent can set or call it. @wire connects a property or function to a data source such as an Apex method or LDS adapter, and updates it automatically when parameters change. @track is now only needed to make LWC notice changes inside an object or array; plain fields are already reactive.
Common mistake: Saying every property needs @track to re-render.
Scenario round
07A page has become slow for users. How do you find and fix the cause?
A page has become slow for users. How do you find and fix the cause?
What the interviewer is checking: A method: measure, find the cause, then fix, instead of guessing.
Measure first: find which page and action is slow, then check with the browser's network tab, Lightning Usage data or the debug log. Common causes and fixes: too many components on the page (use tabs and conditional visibility), Apex returning far more data than shown (select fewer fields, add LIMIT and paging), non-selective queries on big objects (filter on indexed fields), and heavy automation on save (move work to async).
Common mistake: Suggesting fixes before knowing what is slow.
08Process 1 million records in Salesforce. How?
Process 1 million records in Salesforce. How?
What the interviewer is checking: Large data volume basics.
Batch Apex with a QueryLocator, which can cover up to 50 million records, processed in chunks of 200 by default, each with fresh governor limits. Make the start query selective, keep execute bulk-safe, use Database.Stateful only if you need running totals, and report failures in finish(). If the data is coming from outside, Bulk API 2.0 is often better than Apex.
Common mistake: Trying to do it in a trigger or a single Queueable.
09How do you call an external REST API securely from Apex?
How do you call an external REST API securely from Apex?
What the interviewer is checking: Security and error handling, not just the code.
Store the endpoint and authentication in a Named Credential with an External Credential, and give users access with a permission set. In Apex, call callout:My_API/path with HttpRequest; Salesforce adds the authentication, so no secret is in code. Handle non-200 responses, set a timeout and mock the callout in tests with HttpCalloutMock.
Common mistake: Hard-coding the URL and token in Apex or a custom setting.