What is meant by access specifiers?

What is meant by access specifiers?

6 Answers

Relevance
  • 1 decade ago
    Best Answer

    Access specifiers specify how a variable, method or a class can be used. The following are the most commonly used one's:

    Public: Gives variable public access which means that there is no restriction on their accessibility

    Private: Gives variable private access which means that they are accessible only within their declaration content

    Protected: Protected access gives a variable accessibility within their own class or a class derived from that class

    Friend: Gives variable friend access which means that they are accessible within the program that contains their declaration

    Protected Friend: Gives a variable both protected and friend access

    Static: Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends

    Shared: Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure

    ReadOnly: Makes a variable only to be read and cannot be written

  • Anonymous
    6 years ago

    Gives variable public access which means that there is no restriction on their accessibility

  • 1 decade ago

    That we specify for a class member ... like in C++ access specifiers can be : public, private. In Java : public, protected, private.

    Public specifiers can be accessed by code outside the class within which it's declared. But, for private members, it can't be done.

  • Elaine
    Lv 4
    4 years ago

    There is one more, Paul -- default private protected public -- and -- final -- special case functionality When you don't specify a modifer, you get package, all the class definitions of one folder, access private int x; int x; // default, and not a very good choice in OOP

  • How do you think about the answers? You can sign in to vote the answer.
  • 1 decade ago

    access specifiers meant to guarantee that an implementing class can provide that functionality.

    By changing it so say private when it says public you can no longer guarantee that the method will be available to class that tries to use that interface.

Still have questions? Get your answers by asking now.