title: How are java.lang.Object's protected methods protected from subclasses?
body: <p>The keyword <code>protected</code> grants access to classes in the same package and subclasses (<a href="http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html" rel="noreferrer">http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html</a>).</p>
  
  <p>Now, every class has <code>java.lang.Object</code> as superclass (<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" rel="noreferrer">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html</a>).</p>
  
  <p>Hence I conclude that every class may access <code>java.lang.Object</code>'s methods even if they are <code>protected</code>.</p>
  
  <p>Take a look at the following example:</p>
  
  <pre>
  public class Testclass {
    public Object getOne() throws CloneNotSupportedException {
      return this.clone();
    }
    public Object getTwo() throws CloneNotSupportedException {
      return ((Object) this).clone();
    }
  }
  </pre>
  
  <p>While <code>getOne()</code> compiles fine, <code>getTwo()</code> gives</p>
  
  <pre>
  Testclass.java:6: clone() has protected access in java.lang.Object
          return ((Object) this).clone();
  </pre>
  
  <p>I neither understand why <code>getTwo()</code> doesn't compile nor what's the difference (regarding the access of <code>java.lang.Object</code>s members) with <code>getOne()</code>.</p>