title: Java object declaration beyond the common idiom
body: <p>Generally, when a new object is created in Java it follows the idiom:</p>
  
  <pre><code>Object obj = new Object();
  </code></pre>
  
  <p>where the <code>Object()</code> constructor matches the object type <code>Object</code>.</p>
  
  <p>But what if it doesn't? I understand from the Oracle Docs on <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html" rel="nofollow">creating objects</a> and <a href="http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html" rel="nofollow">polymorphism</a> that the constructor must be in that object's class or one of its subclasses.  However, suppose we wanted to declare a new stack.  My first instinct would be:</p>
  
  <pre><code>Stack s1 = new Stack();
  </code></pre>
  
  <p>But I assume it's valid to do it this way, too:</p>
  
  <pre><code>Object s2 = new Stack(); //This
  </code></pre>
  
  <p>Is there a difference here?  What are we really saying about <code>s2</code>?  I'm guessing <code>s2</code> is simply an empty stack, but only has access to the <code>Object</code> class methods?  I'm not sure why someone would ever do this, but I want to solidify my understanding of the Java hierarchy.  Are there really <em>any</em> circumstances where someone would use a subclass's constructor when creating a new object?</p>
  
  <p>Any and all informative responses will be appreciated.  Thanks in advance!</p>