My bad. The error I explained above was from Sridhar's code. I should have mentioned that.
Now what I said before is explained better in following code.
package com.dan.chisholm.other;
import com.dan.chisholm.A;
public class C extends A {
C c1 = new C();
public static void main(
String[] args) {
C c = new C();
c.m1(); // 1
c.m2(); // 2
//c.m3(); // 3
//c.m4(); // 4
}
void m5(A objRefA) {
c1.m2();
objRefA.m2(); //m2() has protected access and cannot be referenced from its superclass. Only by its subclasses. (Different packages are assumed.)
}
}
I am only trying to focus on m2() which is protected.
Thanks
Sandeep