title: When to use abstract class as type
body: <p>So while trying to understand abstract classes, there is still one thing I am confused on. When do you ever want to declare an object type of its abstract class. For example</p>
  
  <pre><code>public abstract class GameObject
  {
   public abstract void draw();
   public static void main(String[] args)
   {
   GameObject player = new Player();
   Menu menu = new Menu();
   }
  
  }
  public class Player extends GameObject
  {
   override 
   public void draw()
   {
   // Something
   }
  
  }
  public class Menu extends GameObject
  {
   override 
   public void draw()
   {
   // Something
   }
  }
  </code></pre>
  
  <p>Normally, I would just instaniate a player object of player type. However, I have seen abstract classes used as the variable type of the new object. When would you ever choose to do this? Thanks!</p>