title: How to allow third party to extend classes in my java library
body: <p>I have a parent class in java with some behavior defined</p>
  
  <pre><code>public class ParentClass {
      public ParentClass() {
          //Do some instantiation
      }
  
      public void doWork() {
         //Do some behavior defined by the parent class
      }
  }
  </code></pre>
  
  <p>Now I have some other class in my project that uses this.  Let's say it is used in main</p>
  
  <pre><code>public class Main {
  
      public static void main(String [] args) {
          ParentClass parent = new ParentClass();
          parent.doWork();
      }
  
  }
  </code></pre>
  
  <p>Now let's say that my project is setup as a Library for other developers to use.  I want them to be able to extend ParentClass and override the doWork() method to their liking.  If the developer can not change the Main class, how can I assure that ChildClass is instantiated in main() instead of ParentClass?</p>
  
  <p>Example of ChildClass</p>
  
  <pre><code>public class ChildClass extends ParentClass {
      public ChildClass() {
          super();
          //Do some more instantiation
      }
  
      @Override
      public void doWork() {
         super.doWork();
         //Do some more behavior in child class
      }
  }
  </code></pre>