Salesforce-Platform-Developer Practice Test

Salesforce Spring 25 Release
237 Questions

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

A. Sharing rules will not be enforced for the running user.

B. Sharing rules will be Inherited from the calling context.

C. Sharing rules will be enforced by the instantiating class.

D. Sharing rules will be enforced for the running user.

B.   Sharing rules will be Inherited from the calling context.

Explanation:

In Apex, if a class is defined without the with sharing or without sharing keyword (as in your example), then it runs in the sharing context of the caller. This is known as inherited sharing behavior.

Example Analysis:

public class myClass {
public void myMethod() {
// implementation
}
}

The class doesn't explicitly specify a sharing context.
Therefore, myMethod will execute in the sharing context of the class or code that called it.

Salesforce-Platform-Developer Practice-Test - Home Previous
Page 14 out of 237 Pages