title: Accessing protected using super
body: <p>I have following code</p>
  
  <pre><code>package com.kathy.accessmodifiers2;
  
  public class base extends Object{
  protected int a = 10;
  }
  
  package com.kathy.accessmodifiers;
  import com.kathy.accessmodifiers2.*;
  
  class derived extends base {
  public void D() {
      System.out.println("D");
      base b = new base();
      System.out.println(super.a); //line 1
      //System.out.println(b.a); //line 2
      //Only this class can access the proctected member.
      System.out.println(this.a);
      System.out.println(a);
  }
  }
  
  class derived2 extends derived {
  public void D2() {
      System.out.println(a);
  }
  }
  
  public class Protected {
  
  public static void main(String str[]) {
      new derived2().D();
  }
  }
  </code></pre>
  
  <p>In line1, i am using <code>super.a</code> and the output is 10. In case of line2, the code does not compile because i am trying to access <code>protected</code> member of <code>super</code> class (different package) from base class (different package). 
  Why in case of <code>super</code> the <code>a</code> is accessible ?</p>