CRT-450 Exam QuestionsBrowse all questions from this exam

CRT-450 Exam - Question 211


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

public Class myClass {

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

}

Show Answer
Correct Answer: B

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.

Discussion

4 comments
Sign in to comment
irina_735Option: A
Sep 15, 2023

Without Sharing is the default for an Apex class. It means you are disabling or ignoring sharing rules.

esabbatiniOption: B
May 23, 2023

It is the default, a is wrong

irina_735Option: B
Oct 10, 2023

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

SS1121Option: A
Jun 14, 2024

Apex without an explicit sharing declaration is insecure by default. We strongly recommend that you always specify a sharing declaration for a class.