This Question is taken from Dans Mock exam
***********************************************
// Class A is declared in a file named A.java.
package com.dan.chisholm;
public class A {
public void m1() {System.out.print("A.m1, ");}
protected void m2() {System.out.print("A.m2, ");}
private void m3() {System.out.print("A.m3, ");}
void m4() {System.out.print("A.m4, ");}
}
// Class C is declared in a file named C.java.
package com.dan.chisholm.other;
import com.dan.chisholm.A;
public class C extends A {
public static void main(
String[] args) {
C c = new C();
c.m1(); // 1
c.m2(); // 2
c.m3(); // 3
c.m4(); // 4
}}
*****************************************
The answer to this question is there is a compiler error in step 3.
How come there isnt error in the step 2 too.
My understanding accordking to the K & B is the subclass can see the protected class through interitance and it cannot use the dot operator (reference)
Please clarify my question.
Thanks,
vijaya