title: Why are methods in class that extends Abstract class running even when not called?
body: <p>Consider the following:</p>
  
  <pre><code>public class OuterClass {
      static class NestedClass extends AbstractList&lt;List&lt;Integer&gt;&gt; {
          void add(/* parameters here */) {
              // note this method is not declared public
              // print here does NOT appear in output
              // implementation details here
          }
  
          public int size() {
              // print here appears in output
              // implementation details here
          }
  
          public List&lt;Integer&gt; get(int index) {
              // print here appears in output
              // implementation details here            
          }
      }
  
       public static List&lt;List&lt;Integer&gt;&gt; method(/* parameters here */) {
           NestedClass nc = new NestedClass();
           nc.add(..);
       }
  }
  </code></pre>
  
  <p>Then in a separate method, I create an instance of <code>NestedClass</code>. When I run the code, without ever invoking <code>get</code> or <code>size</code>, the print statements appear in output. How/why does this happen?  I understand that <code>get</code> and <code>size</code> are necessary since <code>AbstractList</code> is extended, but I am never invoking <code>size</code> or <code>get</code>.</p>
  
  <p>In general, if <code>B</code> extends <code>A</code>, will any call to a method of <code>B</code> inherently invoke the overridden abstract methods implemented in <code>B</code>?</p>
  
  <p>Thanks</p>