title: What happens to protected method of a super class in base class in Java?
body: <p>I have a <code>A</code> class in <code>package1</code> and <code>B</code> is in <code>package2</code> which inherits <code>A</code>. <code>A</code> contains method <code>m1</code> which is <code>protected</code>. Now my doubt is when I create an object of <code>B</code> in another class <code>C</code> which is also <code>package2</code>, the object of <code>B</code> is unable to access method <code>m1</code> why? Below is my code</p>
  
  <pre><code>package com.package1;
  
  public class A {
  
      protected void m1(){
          System.out.println("I'm protectd method of A");
      }
  }
  
  
  package com.package2;
  
  import com.package1.A;
  
  public class B extends A {
  
  
      public static void main(String[] args) {
  
          B b = new B();
          b.m1();          // b object able to access m1
  
      }
  
  }
  
  
  package com.package2;
  
  public class C {
  
      public static void main(String[] args) {
  
          System.out.println("Hi hello");
          B b = new B();
          b.m1(); //The method m1() from the type A is not visible
  
      }
  
  }
  </code></pre>
  
  <p>Do protected method of super class become private in subclass?</p>