title: Cast parent to its child
body: <p>I have:</p>
  
  <pre><code>class A
  {
       public String getID() { return "id of A";}
  }
  
  class B extends A
  { 
       public String getID() { return "id of B"; }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>class C {
   public A returnA() { 
      return new A(); 
    } 
  }
  </code></pre>
  
  <p>Now I somehow need to do:</p>
  
  <pre><code>C c = new C();
  B b = (B)c.returnA(); 
  String id = b.getId();
  </code></pre>
  
  <p>But I don't have access to implementation of <code>C.returnA()</code>, and I can't change return type of it to B. </p>