In the following example, which sharing context myMethod execute when it is invoked?
public Class myClass {
public void myMethod() { /* implementation */ }
}
In the following example, which sharing context myMethod execute when it is invoked?
public Class myClass {
public void myMethod() { /* implementation */ }
}
If a class isn’t explicitly declared with either 'with sharing' or 'without sharing', it inherits the sharing rules from the context in which it was called. Therefore, myMethod will execute with sharing rules inherited from the calling context.
Without Sharing is the default for an Apex class. It means you are disabling or ignoring sharing rules.
It is the default, a is wrong
If a class isn’t explicitly declared as either with sharing or without sharing, the current sharing rules remain in effect. Therefore, the class doesn’t enforce sharing rules except when it acquires sharing rules from another class. For example, if the class is called by another class that has sharing enforced, then sharing is enforced for the called class. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm
Apex without an explicit sharing declaration is insecure by default. We strongly recommend that you always specify a sharing declaration for a class.