title: What's meant by "Data Encapsulation"? Use private data fields or methods?
body: <p>Say I have a <code>ClassA</code> and <code>ClassB</code> extends <code>ClassA</code></p>
  
  <pre><code>ClassA {
      private int x;
  
      private void m1()
      {
  
      }
  }
  
  ClassB extends ClassA {
  
  }
  </code></pre>
  
  <p>Under data encapsulation, we should private the data field and methods. Is that correct?</p>
  
  <p>But, in this case, <code>ClassB</code> can not use <code>ClassA</code>'s data field and methods.</p>
  
  <p>So, under data encapsulation should I use private access modifiers only?</p>
  
  <p>Can I use protected access modifier rather than private to solve the problem under the rule of data encapsulation?</p>