I have two classes in two different packages:
package package1;
public class Class1 {
    public void tryMePublic() {
    }
    protected void tryMeProtected() {
    }
}
package package2;
import package1.Class1;
public class Class2 extends Class1 {
    doNow() {
        Class1 c = new Class1();
        c.tryMeProtected(); // ERROR: tryMeProtected() has protected access in Class1
        tryMeProtected();  // No error
    }    
}
I can understand why there is no error in calling tryMeProtected() since Class2 sees this method as it inherits from Class1.
But why isn't it possible for an object of Class2 to access this method on an object of Class1 using   c.tryMeProtected();   ?
 
     
     
     
     
     
     
     
     
     
     
     
    