title: Java polymorphism method overrides
body: <p>I am writing a program that has 3 specific classes, <code>ImageHandler</code>, <code>TiffHandler</code>, and <code>JPEGHandler</code>.</p>
  
  <p><code>JPEGHandler</code> and <code>TiffHandler</code> both extend <code>ImageHandler</code>. Inside of all 3 classes is a method called compress() which compresses whatever image the object is currently handling.</p>
  
  <p>I am also trying to create a separate class that implements Runnable, but I don't want to have to create two Runnable classes, one for TiffHandler and one for JPEGHandler. I would rather just create a Runnable class that can accept a ImageHandler object.</p>
  
  <p>My issue is that since the Runnable class only has an ImageHandler object, whenever I call compress() it throws errors during runtime saying that:</p>
  
  <pre><code>Uncompilable source code - compress() in fjimagecompressor.JPEGHandler cannot override compress() in fjimagecompressor.ImageHandler
    overridden method does not throw java.io.IOException
  </code></pre>
  
  <p>The second line confuses me, as inside of ImageHandler I have a blank method called compress():</p>
  
  <pre><code>    public void compress() throws IOException{    
          /*blank*/
      }
  </code></pre>
  
  <p>and inside of TiffHandler and JPEGHandler I also have compress() which throws IOException, except compress() does something different depending on if it is a JPEGHandler or a TiffHandler. I am unsure whether I am simply using polymorphism incorrectly or if I am missing something in my super class ImageHandler. Why is the compiler saying that the super method doesn't throw an IOException when I do indeed declare that it does?</p>