Access Specifiers With Real World Example

 Access Specifiers are

1. Public.

2. Private.

3. Default.

4. Protected.

I will explain to you one by one with FaceBook.

Public

In FB create a post, if We select public privacy then Anyone can see this status on the Internet.

Protected

In FB create post, if We select Custom privacy then Visible for your friends and your friends friends.

Default

In FB create post, if We select Friends privacy then Visible for your Friends.

Private

In FB create post, if We select only me privacy then No one can see this status except you.

Now, We will see Access Modifiers in Programming

The public can access within the class, within packages, the same package by subclass, outside package by subclasses, and global.

Protected can access within the class, within packages, same package by subclass, and outside package by subclasses.

Default can access within the class, within packages, and the same package by subclass.

Private can access within the class.

Thank You!!!

Comments

Popular posts from this blog

Object Oriented Programming With Real world Example

The Art of Critical Thinking in Programming

Mastering the Art of Soft Skills: Your Gateway to Success