title: Explicit Type Conversion of sub class object to super class in java
body: <p>Consider below code:</p>
  
  <pre><code>public class Test{
    public static void main(String str[]){
       B b = new B();
       A a1 = (A)b;//Explicit type conversion
       A a2 = b;
    }
  }
  class A{}
  class B extends A{}
  </code></pre>
  
  <p>In the above code are the two line:</p>
  
  <pre><code>A a1 = (A)b;//Explicit type conversion
  A a2 = b;
  </code></pre>
  
  <p>Equivalent? If <strong>not</strong> then what is the <strong>difference between the two</strong> and if <strong>yes</strong> then is there <strong>any scenario in java</strong> where we need to <strong>explicitly convert a sub class object into a super class object</strong>?</p>