You’re offline. This is a read only version of the page.
Contoso, Ltd.
Toggle navigation
Knowledge Base
My Support
All
All
Web Pages
Forums
Cases
Knowledge Articles
Search Filter
All
Web Pages
Forums
Cases
Knowledge Articles
Search
Sign in
CUSTOMER SUPPORT PORTAL
Home
Forums
General Discussion
What are the access modifiers in Java?
What are the access modifiers in Java?
Posted
Tue, 17 Dec 2024 12:18:42 GMT
by
Java provides four access modifiers for controlling the visibility of classes, methods, and variables. These are public.
Public: Accessible from any class in any package.
Protected: Available in the same package and to subclasses in other packages.
Default (Package-private): Accessible only from the same package; does not require a keyword.
Private: Accessible only within the declared class.
These access modifiers enforce encapsulation to the extent of restricting and providing access. For example, a private modifies data toward hiding it. A public permits access to any level with higher usage as well as making it clearly defined upon which interaction.
Know more-
Java Classes in Pune
You must be signed in to post in this forum.