What will automatically obey the organization-wide defaults and sharing settings for the user who executes the code in the salesforce organization?
Reference: A developer has a block of code that omits any statements that indicate whether the code block should execute with or without sharing.Â
Change Image Delete
A. Apex Triggers B. HTTP Callouts C. Apex Controllers D. Anonymous Blocks
The answer is Anonymous Blocks. With the choices that are available, it can be confusing if this is the option or Apex Trigger. Apex Trigger can be used in order to compile data and execute everything that is needed. Apex Trigger can be used in system mode but it is only Anonymous Blocks that can help get user permissions.
Remember that you cannot use Apex Triggers if you want to update a field if you would not be able to use it. You cannot use the other codes that are given to you. The Apex code can get stuck in the metadata but it can be executed when needed.
Though Anonymous block can be excuted in devleoper console without sharing/permission, it need Authour Apex to be enabled for API access. Thus it does comes under normal OWD. But trigger is irrespective of any enabling checkbox.