title: Java abstract classes which throw
body: <p>If I have an abstract class with the following function - </p>
  
  <pre><code>abstract class A{
      void foo(String s) throws Exception{
          throw new Exception("exception!");
      }
  }
  </code></pre>
  
  <p>And then another class that extends the abstract class and implements its own version of foo - </p>
  
  <pre><code>class B extends A{
      void foo(String s){
          //do stuff that does *not* throw an exception
      }
  }
  </code></pre>
  
  <p>Will this create problems? Specifically in the following test case - </p>
  
  <pre><code>Collection&lt;A&gt; col = new Collection&lt;A&gt;();
  B b = new B();
  col.add(b);
  for(A a : col){
      a.foo();
  }
  </code></pre>
  
  <p>I did some testing and nothing seems to have broken, but I don't understand why B's foo was called and not A's</p>