What is the difference between access specifiers and access modifiers?

后端 未结 10 760
我在风中等你
我在风中等你 2020-12-13 02:02

In Java, are access specifiers and access modifiers the same thing?

10条回答
  •  攒了一身酷
    2020-12-13 02:28

    By using access specifier we define that who one can access our class/method and variable(or whatever with that we use access specifier ). basically java access specifier are four types -

    1. public:- Visible to the world,
    2. private:- Visible to the class only,
    3. protected:- Visible to the package and all subclasses, and
    4. default:- Visible to the package

    But access modifier are properties of a class/method/variable. Access modifier are five types

    1. final:- for finalizing the implementations of classes, methods, and variables
    2. static:- for creating class methods and variables
    3. Synchronization and volatile modifiers:- which are used for threads
    4. abstract:- for creating abstract classes and methods
    5. transient

提交回复
热议问题