title: Can we override explicit cast in Java
body: <p>Say I have two classes A and B </p>
  
  <pre><code>Class A {
        int num;
        String name;
  }
  Class B {
        int num;
        String name;
        String age;
  }
  </code></pre>
  
  <p>And I have <code>A extends B</code>  now if I have : </p>
  
  <pre><code>A a;
  B b;
  a = b;
  </code></pre>
  
  <p>But if I do : <code>b = a;</code> which will be explicit cast like this <code>b = (B)a;</code> the cast will be taking care by the java compiler... what if if I wanted to override this default explicit casting.</p>
  
  <p>Say I want <code>b = (B)a</code> to give me something like <code>b</code> with properties a(num) and a(name) and "22" as age of b . If possible how do I do that ? in C# (iOS SDK) it's possible and doesn't give ClassCastException</p>