title: Is there a form of "type safe" casting in Java?
body: <p>Suppose I have two classes deriving from a third abstract class:</p>
  
  <pre><code>public abstract class Parent{
      public Parent(){
      }
  }
  
  public class ChildA extends Parent {
      public ChildA {
      }
  }
  
  public class ChildB extends Parent {
      public ChildB {
      }
  }
  </code></pre>
  
  <p>In C# I could handle casting in a somewhat type safe manner by doing:</p>
  
  <pre><code>ChildA child = obj as ChildA;
  </code></pre>
  
  <p>Which would make child == null if it wasn't a ChildA type object. If I were to do:</p>
  
  <pre><code>ChildA child = (ChildA)obj;
  </code></pre>
  
  <p>...in C# this would throw an exception if the type wasn't correct.</p>
  
  <p>So basically, is there a way to to do the first type of casting in Java? Thanks.</p>