title: Protected class structure in Java?
body: <p>I was wondering if there's a language feature in Java in which methods of a superclass would be invisible for members of a subclass:</p>
  
  <pre><code> public class Subclass extends protected Superclass
  </code></pre>
  
  <p>or something. I'll give an example.</p>
  
  <p>Here is your superclass.</p>
  
  <pre><code>public class A{
      public String getA(){...}
      public String getB(){...}
      public String getC(){...}
      public void setA(String a){...}
      public void setB(String b){...}
      public void setC(String c){...}
  }
  </code></pre>
  
  <p>If you want to subclass A while protecting some of its methods, and you can't change access modifyers in methods unless you override them, you'd end up with something like this-</p>
  
  <pre><code>public class B extends A{
      private String getA(){return super.getA();}
      private String getB(){return super.getB();}//These four methods have
      private void setA(String a){super.setA(a);}//to be redeclared.
      private void setB(String b){super.setB(b);}
  
      public String getC(){return super.getC();}//These two methods can be
      public void setC(String c){super.setC(c);}//removed.
      public String getD(){...}
      public void setD(String d){...}
  }
  </code></pre>
  
  <p>Either that or you can keep a private instance of A and have something like this:</p>
  
  <pre><code>public class B{
  
      private A obj;
  
      private String getA(){return obj.getA();}
      private String getB(){return obj.getB();}//These four methods can also
      private void setA(String a){obj.setA(a);}//be removed.
      private void setB(String b){obj.setB(b);}
  
      public String getC(){return obj.getC();}//These two methods are
      public void setC(String c){obj.setC(c);}//redeclared.
      public String getD(){...}
      public void setD(String d){...}
  }
  </code></pre>
  
  <p>Can you have something that takes both in a way that you don't have to redeclare any methods?</p>