title: Instantiating an object outside the methods or construcor?
body: <p>I am getting confused over this:</p>
  
  <pre><code>class ClassA {
  
     ClassB car = new ClassB();
  
     ClassA(){
     }
  
     someMethod(){
     }
  
  }
  
  
  ClassC{
  
     ClassC(){    
     }
  
     someMethod(){
          ClassA spaceship = new ClassA();
     }
  
  }
  </code></pre>
  
  <ul>
  <li><p>Class B is not instantiated in the Constructor or in the
  methods. And it is not declared as static either. So, when exactly classB is
  instantiated? </p></li>
  <li><p>How long does the 'car' instance live for? In other
  words, what happens to the 'car' instance (of Class B) if the
  'spaceship'instance (of ClassA) gets garbage collected?</p></li>
  </ul>