title: Overridden methods cannot throw exceptions Java
body: <p>This is my code block.</p>
  
  <pre><code>class Alpha{
      public void Gamma() {
          System.out.println("Alphas");
      }
  }
  
  class Beta extends Alpha{
      public void Gamma() throws Exception //Line 1
      {
          try {
              System.out.println("Betas");
          } catch(Exception e) {
              System.out.println("Exception caught");
          } finally {
              System.out.println("xfg");
          }
      }
      public static void main(String[] args) throws Exception {
          Alpha g = new Beta();
          g.Gamma();
      }
  }
  </code></pre>
  
  <p>This code fails to compile because I have added "throws" in Line1.</p>
  
  <p>The compiler complains that overridden methods cannot throw exceptions.</p>
  
  <p>Why so ?.</p>
  
  <p>Why cant an overridden method throw an exception ?.</p>
  
  <p>Because I can override a method from a base class by adding n lines of code in the child's class implementation.</p>
  
  <p>And these added code can throw an exception so why I cant use "throws" in the overridden method ?.</p>