title: Using Object variables to reference new data types/objects
body: <p>I have had a burning question for a long time now, relating to the Java syntax and why it allows this:</p>
  
  <pre><code>Object object1 = new Integer();
  </code></pre>
  
  <p>Why can we declare child classes using Object as a reference?
  Also, let's take a look at this piece of code:</p>
  
  <pre><code>public class Parent{}    
  public class Child extends Parent{}
  
  public static void main(String[] args){
     Parent var1 = new Child();                
     Object var2 = new Child();
     Object var3 = new Parent();                
  }
  </code></pre>
  
  <p>All three cases will run, as I have tried this. The question is, does it matter whether I use Object to reference a new object/variable or the actual class name? 
  Also, how does the reference type selected affect the program and code? Does a certain reference type like "Object" take up less memory or make the program more efficient?
  Thanks in advance</p>