Saturday, January 16, 2016

What is Access Specifier?

Access Specifier:

The access specifier determines how accessible the field is to code in other classes.

4 types:

Public:

Anything declared as public can be accessed from anywhere means outside the class accessibility will be possible.

Private: 

Anything declared as private can not be accessed outside the class.

Protected: 

Anything declared as protected can be accessed inside the same package and subclass of the different package.

Default:

 Anything declared as default can be accessed only to classes in the same package.

No comments:

Post a Comment