title: Why should I  extend a class?
body: <p>Right now I am confused with inheritance and object of class. We can do the same using object as inheritance does.
  ok here is first code</p>
  
  <pre><code>public class MainForm {
      GUI g = new GUI();
      g.show();
      g.destroy();
  }
  class GUI {
      void show(){
          ......
      }    
      void destroy (){
          ......
      }
  }
  </code></pre>
  
  <p>now second one</p>
  
  <pre><code>public class MainForm extends GUI {
      //GUI g = new GUI();
      void show();
      void destroy();
  }
  class GUI {
      void show(){
          ......
      }    
      void destroy (){
          ......
      }
  }
  </code></pre>
  
  <p>both code do the same.Right? then
  Why should I extend a class when i can do the same using an object of class?</p>