title: Different object and reference
body: <p>I was trying to learn Java from Tutorials Point. So, may be this question would be so basic. But I am really stuck here. And I don't know what to google to get it resolved. </p>
  
  <p>Please have a look at this program.</p>
  
  <pre><code>class Animal{
  
     public void move(){
        System.out.println("Animals can move");
     }
  }
  
  class Dog extends Animal{
  
     public void move(){
        System.out.println("Dogs can walk and run");
     }
  }
  
  public class TestDog{
  
     public static void main(String args[]){
        Animal a = new Animal(); 
        Animal b = new Dog(); 
  
        a.move();// runs the method in Animal class
  
        b.move();//Runs the method in Dog class
     }
  }
  </code></pre>
  
  <p>Please have a look at the object creation.</p>
  
  <pre><code>Animal a = new Animal(); 
  Animal b = new Dog(); 
  </code></pre>
  
  <p>What is the difference between these two? I am familiar with the first one. Could someone explain in simple terms what happens when an object is defined in the second way?</p>