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

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

public class myClass {

public void myMethod () {/*implementation*/}

}
A . Sharing rules will be inherited from the calling context.
B . Sharing rules will not be enforced for the running user.
C . Sharing rules will be enforced by the instantiating class.
D . Sharing rules will be enforced for the running user.

Answer: B

Explanation:

In the provided class:

public class myClass {

public void myMethod() { /* implementation */ }

}

The class myClass is declared without any sharing keyword (with sharing, without sharing, or

inherited sharing).

Default Sharing Behavior:

Apex classes without an explicit sharing declaration run in system context, meaning they do not enforce sharing rules.

Option B: Sharing rules will not be enforced for the running user.

Since myClass does not specify with sharing, methods within it execute without enforcing sharing rules, allowing access to all data irrespective of the running user’s sharing rules.

Reference: "If a class is not declared as either with sharing or without sharing, the class does not enforce sharing rules except when it acquires sharing rules from another class."

― Apex Developer Guide: Using the with sharing or without sharing Keywords Why Other Options Are Incorrect:

Option A: Sharing rules are not inherited from the calling context unless inherited sharing is used.

Option C: There is no instantiating class that enforces sharing in this context.

Option D: Sharing rules are not enforced unless with sharing is specified.

Latest DEX-450 Dumps Valid Version with 456 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments