Plat-Dev-201 practice question 20 of 30

In the following example, which sharing context will myMethod execute when it is invoked?

Full set: 204 questions
Answer options
A: Sharing rules will be enforced by the instantiating class.
B: Sharing rules will be enforced for the running user.
C: Sharing rules will not be enforced for the running user. Correct answer
D: Sharing rules will be inherited from the calling context.
Correct Answer:
C. Sharing rules will not be enforced for the running user.
Explanation

Declaring a class or method with the keyword without sharing explicitly turns off enforcement of the caller’s or the running user’s sharing rules. Therefore, when myMethod is invoked it executes in system context, ignoring all record-level sharing rules for the user.

Why Incorrect

A. Instantiating class’s sharing is irrelevant once without sharing is specified.
B. without sharing disables enforcement for the running user.
D. Inheritance occurs only when no sharing keyword is specified; here it is explicitly without sharing.

References

1. Salesforce Apex Developer Guide, Winter ’24, section “With Sharing and Without Sharing Keywords,” para. “Effect of without sharing”.

2. Trailhead Module “Apex Security and Sharing,” unit “Run Apex Without Sharing,” bullet 2.

Scroll to Top