Cloud Kicks Fitness, an ISV Salesforce partner, is developing a managed package application. One of the application modules allows the user to calculate body fat using the Apex class, BodyFat, and its method, calculateBodyFat(). The product owner wants to ensure this method is accessible by the consumer of the application when developing customizations outside the ISV’s package namespace.
Which approach should a developer take to ensure calculateBodyFat() is accessible outside the package namespace?
A. Declare the class and method using the public access modifier.
B. Declare the class as global and use the public access modifier on the method.
C. Declare the class as public and use the global access modifier on the method.
D. Declare the class and method using the global access modifier.
D. Declare the class and method using the global access modifier.
Explanation:
When developing a managed package as an ISV (Independent Software Vendor), certain access modifiers determine whether code is accessible outside the package's namespace.
To make Apex code usable by subscribers of a managed package, the access level must be global.
Why D is Correct:
global access modifier allows the class and method to be accessed outside the managed package, including by orgs that install the package.
This is the only access level that makes Apex components externally accessible from a managed package.
Both the class and its method must be declared global to allow access.