受保护的构造函数和可访问性
如果一个类的子类位于不同的包中,为什么我们不能用受保护的构造函数实例化该类?如果可以访问受保护的变量和方法,为什么相同的规则不适用于受保护的构造函数?
包1:
package pack1;
public class A {
    private int a;
    protected int b;
    public int c;
    protected A() {    
        a = 10;
        b = 20;
        c = 30;
    }
}
包装2:
package pack2;
import pack1.A;
class B extends A {
    public void test() {
        A obj = new A(); // gives compilation error; why?
        //System.out.println("print private not possible :" + a);
        System.out.println("print protected possible :" + b);
        System.out.println("print public possible :" + c);
    }
}
class C {
    public static void main(String args[]) {
        A a = new A(); // gives compilation error; why?
        B b = new B();
        b.test();
    }
}