title: Casting and dynamic vs static type in Java
body: <p>I'm learning about static vs dynamic types, and I am to the point of understanding it for the most part, but this case still eludes me.</p>
  
  <p>If class <code>B</code> extends <code>A</code>, and I have:</p>
  
  <pre><code>A x = new B();
  </code></pre>
  
  <p>Is the following allowed?:</p>
  
  <pre><code>B y = x;
  </code></pre>
  
  <p>Or is explicit casting required?:</p>
  
  <pre><code>B y = (B) x;
  </code></pre>
  
  <p>Thanks!</p>