Leave a Reply 4

Your email address will not be published. Required fields are marked *


renko

renko

Answer: B
package q076;

public class Acc {
int p;
private int q;
protected int r = 9;
public int s = 10;
}
package q075;
import q076.Acc;

public class Test extends Acc {

public static void main(String[] args) {
Acc obj = new Test();
System.out.println(“p = “+obj.p +”s = “+obj.s +” r = “+ obj.r);
System.out.println(“Only s is visible: => child.member with protected modifier”);
}
}
/* Output:
Exception in thread “main” java.lang.Error: Unresolved compilation problems:
The field Acc.p is not visible
The field Acc.r is not visible

at q075.Test.main(Test.java:8)
*/

renko

renko

Only child reference is allowed.