• Welcome to Web Hosting Forum - A Web Hosting Community for Webmasters.
 

Recommended Providers



WordPress Hosting

Jetpack
Fully Managed WordPress Hosting
lc_banner_leadgen_3
Fully Managed WordPress Hosting

WordPress

WordPress Hosting Divi WordPress Theme
WPZOOM
Bluehost WordPress Hosting

Forum Membership

Forum Membership

Types of Access Modifiers

Started by grofee, March 06, 2023, 03:36:27 PM



grofee

Types of Access Modifiers:
1. Private: We can access the private modifier only within the same class and not from outside the class.
2. Default: We can access the default modifier only within the same package and not from outside the package. And also, if we do not specify any access modifier it will automatically consider it as default.
3. Protected: We can access the protected modifier within the same package and also from outside the package with the help of the child class. If we do not make the child class, we cannot access it from outside the package. So inheritance is a must for accessing it from outside the package.
4. Public: We can access the public modifier from anywhere. We can access public modifiers from within the class as well as from outside the class and also within the package and outside the package.

Akshay_M

Simply put, there are four access modifiers: public, private, protected and default (no keyword)


WordPress Hosting