Access Modifiers in apex

Bynayakdillip

Access Modifiers in apex

Apex has four access modifiers

Private
Public
Protected
Global

Private :If you define private that you don’t want outside code to call(like within class).in other words, methods used by the
public methods of your class.

Note: If you do not specify an access modifier, the method or variable is private.

Public :If you define public that use within class as well as outside the class means any code anywhere can access
the public .

protected : if you define protected it access to any inner class and to the classes that extend the defining apex
class.

global:if you define global it can used by apex code that has access to the class .not just the apex code in
the same application it also access outside of the application like Rest API/SOAP API.

About the author

nayakdillip administrator

Leave a Reply