title: Java - Does null variable require space in memory
body: <p>Consider the following block of code:</p>
  
  <pre><code>class CheckStore {
      private String displayText;
      private boolean state;
      private String meaningfulText;
      private URL url;
  
      public CheckStore(String text, boolean state) {
          this.displayText = text;
          this.state = state;
      }
      :
      :
  }
  </code></pre>
  
  <p>When I initialize two variables (<code>displayText</code> and <code>state</code>) in the constructor, do the other two variables (<code>meaningfulText</code> and <code>url</code>) require space in the memory to store <code>null</code> value?</p>
  
  <p>Q1. If they do require space, how much memory does a <code>null</code> value take in the memory? 
  (ex. <code>int</code> takes 4 bytes).</p>
  
  <p>Q2. How much space does a string take in memory? How much memory space does a string take? Does it depend on the length of the string? </p>