title: Accessing protected members outside package with child class reference
body: <pre><code>package pack1;
  class A{
     protected void m1(){
        System.out.println("protected modifier");
     }
  }
  
  package pack2;
  class B extends A{
      public static void main(string[]args){
           B b = new B();//Valid
           b.m1();
  
          A a = new B();//Invalid
            a.m2();
  
         A a1 = new A();//InValid
           a1.m1();
  
     }
  }
  </code></pre>
  
  <p>Why while accessing protected members outside package we need to have child class reference only.?</p>
  
  <p>Why we cant use parent reference to access protected members (Here A a = new B())?</p>
  
  <p>I have gone through blogs and many stack overflow answers but didn't find any answer for WHY?.</p>
  
  <p>so can anyone help me knowing the answer for WHY?</p>