There are two levels of access modifiers such as top level access and member level access.
Top level access
This is related to class definition. A class can be public or package-private.
Declaring as public, a class can be accessed to any class and outside the application as well. ย Package-private means you can declare a class with any modified by default it will nominate as package-private.
Member level access
This is for member level access modifiers such as properties, methods and so on. This can be chopped in to four modifiers such as public, private, protected and package-private.
Here public and private modifiersโ€™ accessibilities are same as top level access which is described above.
The new two member level modifiers are private and protected.

  1. Private โ€“ This modifier can only be accessed via same class.
  2. Protected โ€“ This modifier can only be accessed via same package.

For further additions package-private modifiers cannot be access via sub classes of out of package.

Reference URL

14 thoughts on “Access Modifiers in Java

  1. Great post. I was checking continuously this blog and I am impressed!

    Extremely helpful info particularly the last part ๐Ÿ™‚ I care for such info
    a lot. I was looking for this certain information for
    a very long time. Thank you and best of luck.

  2. What i do not realize is in fact how you’re no longer really a lot
    more smartly-preferred than you might be right
    now. You are very intelligent. You realize thus considerably in relation to this matter,
    made me in my view imagine it from a lot of various angles.
    Its like men and women are not interested unless it is
    something to do with Lady gaga! Your personal stuffs excellent.
    At all times care for it up!

  3. Awesome blog you have here but I was wondering if you
    knew of any discussion boards that cover the
    same topics discussed here? I’d really love to be a part of
    group where I can get opinions from other knowledgeable people that
    share the same interest. If you have any recommendations, please let me know.

    Bless you!

Leave a Reply

Your email address will not be published. Required fields are marked *

WP Facebook Auto Publish Powered By :