Default access specifier


AutomationChinnu

If we don’t specify any access specifiers like Public, Private and Protected for the instance variables and methods of a class, we call it as default access specifier.

In case of default access specifier, all the methods and instance variables will be ‘public’ (i.e. accessible)  by default for all the classes inside the package, but where as they will be ‘private’  (i.e. not accessible) by default  for the code that is outside the package.

In our previous post, we’ve specified all the instance variables and methods of the class as ‘public’. In this case the code inside the package and outside the package is able to access the instance variables and methods which are specified as public. Click here to download this project and follow the below steps to find out how the default access specifier controls the access:

1. Import the downloaded project into Eclipse IDE and ensure that…

View original post 304 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s