Java Access Modifiers


  1. PUBLIC: access by any class & any package…..
  2. PRIVATE: can be accessed by only that class & not even by other classes of that package………
  3. PROTECTED: can be accessed by that class  & it's package but can't be accessed by other packages….
  4. FINAL: s for that class which can't be derived (inherited) ….final with var makes it constant var (e,g final Pi=3.14 )& if we put final with method then that method can't be overwritten…
  5. ABSTRACT: (conceptual/theoretical) we can't make directly objects from it but we've to make inherited classes from it then it can be used ,we can't call abstract func directly……
  6. NATIVE: it informs java that a method’s implementations s an external C file that’s why it’s declearation s different that is    native int me( ) ;  . so it’s used to embed another lang prog in to java , but then java will become machine dependant..
  7. SYNCRONIZE: that a method s thread safe. Two or more prog can run at same time.

if we haven't put any access modifier then by default automatically it'll protected