Salesforce Platform Developer I (legacy) — Question 119
A developer must create an Apex class, ContactController, that a Lightning component can use to search for Contact records. Users of the Lightning component should only be able to search for Contact records to which they have access.
Which two will restrict the records correctly? (Choose two.)
Answer options
- A. public class ContactController
- B. public with sharing class ContactController
- C. public without sharing class ContactController
- D. public inherited sharing class ContactController
Correct answer: B, D
Explanation
The correct answers are B and D because 'public with sharing' enforces sharing rules, ensuring that only records the user has access to are returned. 'public inherited sharing' respects the sharing settings of the class that it extends and is also appropriate for this scenario. Options A and C do not enforce sharing rules, potentially exposing records that the user should not have access to.