Four Access Modifiers Access Rights in Java

    For students who have just graduated , the interview will be a relatively easy topic (I encountered a few times when I just graduated in the interview). After all, these four access modifiers are relatively basic knowledge points, generally memorize permission access first. The more "strict" private access modifiers are memorizing others. Of course, you choose the memory method you are good at to understand it. After all, rote memorization will forget it soon. The foundation is still very important.

    

Four Access Modifiers in Java
access modifier
   this class
   Same package
   Subclass
   other
private
    √
     ×
 ×
 ×
Default (friendly)
    √
      √
 ×
 ×
protected
    √
      √
    √
 ×
public
    √
      √
     √
  √

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324709106&siteId=291194637