title: Java: Why can't I cast this to an Object?
body: <p>This is bizarre... I thought every object in java had Object as an ancestor.</p>
  
  <p>I have a <code>ClassA</code> that extends my <code>ClassB</code> and implements <code>Runnable</code>.</p>
  
  <p>After creating <code>ClassA</code> I cannot cast it to an <code>Object</code>.</p>
  
  <p>Assume <code>getClassA</code> returns a <code>ClassA</code> instance.</p>
  
  <p>I am doing </p>
  
  <pre><code>Object obj = getClassA();
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>Object obj = (Object) getClassA();
  </code></pre>
  
  <p>I get an incompatible types compile error: found Class, required Object.</p>
  
  <p>What's the deal with that?  I thought all objects could be cast to Object.</p>
  
  <p>Edit: I assume it has something to do with the fact that ClassA implements Runnable, but I am not sure and need an explanation.</p>
  
  <p>Edit2: Changing getClassA() to return an Object allows the program to compile.</p>
  
  <p>Edit3: Importing the package that contained ClassB fixed the problem.  Class B was defined in a different jar.  ClassA was defined in another jar that referenced the jar containing ClassB.</p>