title: Why Junit throws java.lang.ClassCastException even if classes are compatible and works fine in java code
body: <p>I have class Car, and class Vehicle.
  and  Car extends Vehicle.</p>
  
  <p>When i am writing junit for below method it gives class cast exception.
  On type casting line. </p>
  
  <pre><code>   void method(){
      // some code
      Car a = (Car)Vehicle;
      // some code
      }
  </code></pre>
  
  <p>it throws exception as 
      java.lang.ClassCastException: com.abc.Vehicle cannot be cast to com.abc.Car</p>