In Salesforce Apex has 4 Access Modifiers:
Private : This is the default and means that the method or variable is accessible only within the Apex in which it is defined. If we do not specify an access modifier, the method or variable is private.
Protected : This means that the method or variable is visible to any inner classes in the defining Apex class, and to the classes that extend the defining Apex class. We can only use this access modifier for instance methods and member variables.
Public : This means the method or variable can be used by any Apex in this application or namespace.
Global : This means the method or variable can be used by any Apex code that has access to the class, not just the Apex code in the same application. This access modifier should be used for any method that needs to be referenced outside of the application, either in the SOAP API or by other Apex code. If you declare a method or variable as global, you must also declare the class that contains it as global.