title: In Java what happens when an object fails to be instantiated?
body: <p>I come from a c++ background and I find myself constantly doing this in java:</p>
  
  <pre><code>SomeClass sc=new SomeClass();
  
  if(null!=sc)
  {
      sc.doSomething();
  }
  </code></pre>
  
  <p>What I want to know is what will be in the variable sc if the constructor fails for some reason (like maybe not enough memory).  I can'
  t find a straight answer, and I am worried that I am just wasting my time because maybe if the new operator fails would the program just crash anyway?</p>